How To See The Command History (CMD, PowerShell) Across All PowerShell Sessions.
March 07, 2025
Open PowerShell (Press Win + X and select "Windows PowerShell" or "Windows PowerShell (Admin)" if needed).
Run the command to check where your history file is stored:
cat (Get-PSReadlineOption).HistorySavePath
This command will display the file path where your history is saved. The command uses PSReadline to retrieve the history save path and then cat (which is an alias for Get-Content) to display the content of the history file.
Explanation:
Get-PSReadlineOption: Retrieves options from the PSReadline module.
.HistorySavePath: This property returns the file path of where command history is stored.
cat: This is shorthand for Get-Content, which displays the file’s content (the saved command history).