(EDIT 2: now including the output of Get-Module
)
In a Powershell prompt I have persistent history across sessions (see this related question).
But when I launch the Powershell ISE, I do not have access to that same history, since they seem to use different files.
In a regular PS prompt:
> (Get-PSReadlineOption).HistorySavePath
C:\Users\USER1\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
> Get-Module
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}
Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Script 2.0.0 PSReadline {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PSReadLineKeyHandler, Set-PSReadLineKeyHandler...}
In an ISE prompt (I have a Spanish version):
> (Get-PSReadlineOption).HistorySavePath
C:\Users\USER1\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\Windows PowerShell ISE Host_history.txt
> Get-Module
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.0.0.0 ISE {Get-IseSnippet, Import-IseSnippet, New-IseSnippet}
Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Cont...
Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Script 2.0.0 PSReadline {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PSR...
Is there a way to get such persistent history (even if not shared with the regular prompt)?
Would it make sense to have both histories pointing at the same file, if even possible?
EDIT:
It may be the case that Readline cannot be used with ISE...
... But as per EDIT 2, PSReadLine
can also be loaded in ISE.
Why would history not be persistent?
Set-PSReadLineOption -HistorySavePath …
> (Get-PSReadLineOption).HistorySaveStyle \nSaveIncrementally
. Official docs (docs.microsoft.com/en-us/powershell/module/psreadline/…) mention: "SaveIncrementally: Save history after each command is executed and share across multiple instances of PowerShell."Windows PowerShell ISE Host_history.txt
does not exist at all asTest-Path ((Get-PSReadlineOption).HistorySavePath)
returns false. Anyway, thePSReadLine
module isn't active in ISE by default.