PowerShell command history on Windows 10 using PSReadline

In Windows 10 PowerShell 5.0 comes bundled with PSReadline. This module allows for getting access to the command history.

PowerShell command history on Windows 10 using PSReadline

In Windows 10 PowerShell 5.0 comes bundled with PSReadline. This module allows for getting access to the command history.

A very useful feature of PSReadline is that it writes the history of PowerShell commands to a text file and this text file is easily accessible. The path where this file is stored can be found by executing the following command:

(Get-PSReadlineOption).HistorySavePath

To view the list of previously executed commands you can type the following:

Get-Content -Path (Get-PSReadlineOption).HistorySavePath

This will output the contents of the history file to your PowerShell console. Alternatively the file can be opened by your favorite editor by using the Invoke-Item cmdlet:

Invoke-Item -Path (Get-PSReadlineOption).HistorySavePath

 

C:\Windows\Logs\CBS\CBS.log.