How to Get Previous PowerShell Command History on Windows 10

Updated May 2024: Stop getting error messages and slow down your system with our optimization tool. Get it now at this link
  1. Download and install the repair tool here.
  2. Let it scan your computer.
  3. 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 *

May 2024 Update:

You can now prevent PC problems by using this tool, such as protecting you against file loss and malware. Additionally, it is a great way to optimize your computer for maximum performance. The program fixes common errors that might occur on Windows systems with ease - no need for hours of troubleshooting when you have the perfect solution at your fingertips:

  • Step 1 : Download PC Repair & Optimizer Tool (Windows 10, 8, 7, XP, Vista – Microsoft Gold Certified).
  • Step 2 : Click “Start Scan” to find Windows registry issues that could be causing PC problems.
  • Step 3 : Click “Repair All” to fix all issues.

Download Now

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:

Remove-Item (Get-PSReadlineOption).HistorySavePath

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

Scroll to Top