How can I see the command history across all PowerShell sessions in Windows Server 2016? How can I see the command history across all PowerShell sessions in Windows Server 2016? powershell powershell

How can I see the command history across all PowerShell sessions in Windows Server 2016?


In PowerShell enter the following command:

(Get-PSReadlineOption).HistorySavePath

This gives you the path where all of the history is saved. Then open the path in a text editor.

Try cat (Get-PSReadlineOption).HistorySavePath to list the history in PowerShell.


The Psreadline module 2.1 beta1 on Powershell gallery (Powershell 7 only) https://www.powershellgallery.com/packages/PSReadLine/2.1.0-beta1 does intellisense on the commandline using the saved history: https://github.com/PowerShell/PSReadLine/issues/1468 It's been starting to show up in Vscode. https://www.reddit.com/r/PowerShell/comments/g33503/completion_on_history_in_vscode/

Also in Psreadline, you can search the saved history backwards with either f8 (after typing something on the command line) or control-R. Get-psreadlinekeyhandler lists the key bindings.

get-psreadlinekeyhandler -bound -unbound | ? function -match history


For getting full history from PowerShell and save the output to file I use this command:

Get-Content (Get-PSReadlineOption).HistorySavePath > D:\PowerShellHistory.txt