Updated January 2023: Stop getting error messages and slow down your system with our optimization tool. Get it now at this link
- Download and install the repair tool here.
- Let it scan your computer.
- The tool will then repair your computer.
PowerShell on Windows 10 can show you a history of every command you have executed in the current session, but for many users this is not enough. You need a history of the commands that have been executed in different sessions. If you need the history of PowerShell commands and the history alone is not enough for the current session, there is a script and log file that can help you.
How to View the PowerShell History
Windows PowerShell itself keeps a history of the commands you entered in the current PowerShell session. You can use several included cmdlets to view and work with the history.
To view the history of the commands you entered, launch the following cmdlet :
You can browse your history by passing the result to the Select-String cmdlet and specifying the text to be found. Replace the example in the cmdlet below with the text you want to search for:
Get-History | Select-String -Pattern "Example"
To view a more detailed command history that shows the execution status of each command as well as the start and end times, execute the following command:
Get-History | Format-List -Property *
By default, the Get-History cmdlet displays only the 32 most recent entries in history. To display or search for more history entries, use the -Count option to specify how many history entries you want PowerShell to display, like this:
- Get-History -Count 1000
- Get-History -Count 1000 | Select-String -Pattern “Example”
- Get-History -Count 1000 | Format-List -Property *
View full PowerShell Command History for this Session
Enter the history and press Enter. You should be able to see all the commands you have executed in the current session. Although you can use the arrow keys to display commands you executed in the previous session, you cannot do this in history. If you press the H key and press the Enter key, the command history displays. Think of this as a shortcut to the History command.
To Clear the Command History in PowerShell
As explained above, the PSReadline module stores all the commands of the PowerShell console in a text file. However, in some cases, the administrator must enter various confidential information into the PowerShell console (credentials, passwords, addresses, personal information, etc.) This allows another server administrator or attacker to access the history information in a simple text file. For security reasons, you may need to delete the history of PowerShell commands that have been executed or disable the command history completely.
You cannot use the Clear-History cmdlet to delete the command history. It only deletes the list of previous commands that the Get-History cmdlet displays.
To clear the history of previous PoSh commands, you must delete the file in which those commands are stored. The easiest way is to use the:
Then close the PoSh window.
If you want to completely disable storing the PoSh command history in a text file, run the :
Set-PSReadlineOption -HistorySaveStyle SaveNothing
You can open this CSV or XML file at any time to immediately view the PowerShell command history. This summarizes just about everything about PowerShell’s command history and how you can reuse it by focusing on it or searching for it or importing it the next day.
Expert Tip: This repair tool scans the repositories and replaces corrupt or missing files if none of these methods have worked. It works well in most cases where the problem is due to system corruption. This tool will also optimize your system to maximize performance. It can be downloaded by Clicking Here
CCNA, Web Developer, PC Troubleshooter
I am a computer enthusiast and a practicing IT Professional. I have years of experience behind me in computer programming, hardware troubleshooting and repair. I specialise in Web Development and Database Design. I also have a CCNA certification for Network Design and Troubleshooting.