In Windows 10 PowerShell 5.0 comes bundled with PSReadline. This module allows for a number of useful features and today we will focus on 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
A very useful feature if you accidentally closed your console without saving your command history.