PowerShell history

The PowerShell history can contain sensitive information such as password enter through commandline ex.

Read history file

You can find the full history in the following text file:

%userprofile%\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt

or use this command to get the full path:

(Get-PSReadlineOption).HistorySavePath

Clearing history file

Remove-Item (Get-PSReadlineOption).HistorySavePath

Do you want to set another location for this file?

Use the following command with -HistorySavePath parameter to specify a new path:

Set-PSReadlineOption –HistorySavePath C:\Temp\History.txt

Last updated