PowerShell Commands History File Location

The Get-History command in PowerShell lists only the commands entered during the current session, unlike the history command in Linux or MacOS, that returns the full commands history across all sessions.

To get the history of all the previously executed commands in PowerShell it is required to locate the file where these commands are stored.

In this note I’ll show how to locate the history file and get the history of all the previously executed commands in PowerShell.

Cool Tip: Clear history of previous commands in PowerShell! Read more →

Command History in PowerShell

To get the PowerShell commands history file location, execute:

PS C:\> (Get-PSReadlineOption).HistorySavePath

To show the PowerShell commands history, execute:

PS C:\> cat (Get-PSReadlineOption).HistorySavePath

The command above will print the full PowerShell commands history across all sessions.

You can also search through the PowerShell commands history, as follows:

PS C:\> cat (Get-PSReadlineOption).HistorySavePath | Select-String <Something>
Was it useful? Share this post with the world!

Leave a Reply