1

(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?

4
  • Set-PSReadLineOption -HistorySavePath …
    – JosefZ
    Jul 9, 2020 at 22:05
  • @JosefZ - That is spot-on. Now I wonder why I don't have persistent history in ISE if I have > (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." Jul 9, 2020 at 22:22
  • ISE is deprecated? Nonetheless, I use ISE often and noticed that the file Windows PowerShell ISE Host_history.txt does not exist at all as Test-Path ((Get-PSReadlineOption).HistorySavePath) returns false. Anyway, the PSReadLine module isn't active in ISE by default.
    – JosefZ
    Jul 9, 2020 at 22:35
  • @JosefZ - As I read, ISE is not under development, but it will keep having some limited support so as to stay functional. As for history, would you have any hint on how to make it work under ISE? Jul 9, 2020 at 22:54

0

You must log in to answer this question.

Browse other questions tagged .