3

When running Powershell 5.1.19041.1682 in the Powershell_ISE Version 10.0.19041.1 (Windows 10) host the HistorySavePath property is set to a full file path however the file is never created after running commands in the ISE window. I have executed commands in the ISE Script pane, the output pane, saved a ps1 file, closed the ISE Host and re-opened. The HistorySavePath file is never created.

When running Powershell in a Console host the file denoted by the HistorySavePath property (Consol eHost_history.txt) is created and history is written to the file. Also, (Get-PSReadLineOption).AddToHistoryHandler is populated for the Console Host but is blank for the ISE Host.

Why is the "Windows PowerShell ISE Host_history.txt" history file missing and AddToHistoryHandler blank for ISE Host ?

- ISE Host PSReadLine Option

>Get-PSReadLineOption

EditMode                               : Windows
AddToHistoryHandler                    : 
HistoryNoDuplicates                    : True
HistorySavePath                        : C:\Users\Admin\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\Windows PowerShell ISE Host_history.txt
HistorySaveStyle                       : SaveIncrementally
HistorySearchCaseSensitive             : False
HistorySearchCursorMovesToEnd          : False
MaximumHistoryCount                    : 4096 

- Console Host PSReadLine Option

   >Get-PSReadLineOption

EditMode                               : Windows
AddToHistoryHandler                    : System.Func`2[System.String,System.Object]
HistoryNoDuplicates                    : True
HistorySavePath                        : C:\Users\Admin\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\Consol
                                         eHost_history.txt
HistorySaveStyle                       : SaveIncrementally
HistorySearchCaseSensitive             : False
HistorySearchCursorMovesToEnd          : False
MaximumHistoryCount                    : 4096
  • There's a related answer here, but it doesn't satisfactorily explain why PSReadLine is inactive in PowerShell ISE: https://stackoverflow.com/questions/67589348/wheres-the-command-history-in-powershell-ise-stored-at – mjsqu Oct 25 '22 at 03:55
  • The documentation here states "[PSReadLine] doesn't work in the Windows PowerShell ISE": https://learn.microsoft.com/en-us/powershell/module/psreadline/about/about_psreadline?view=powershell-7.2 – mjsqu Oct 25 '22 at 03:57

1 Answers1

0

ISE is deprecated since many years, you better not use it anymore because of the environment and several cmdlets behave differently and VSCode is far superior for linting, code highlighting and working with modern PowerShell versions 7+.

itpropro
  • 160
  • 1
  • 7
  • It's still being installed on standard Windows images - how is that deprecated? – charles ross Jul 03 '23 at 02:22
  • It is the same as many other legacy parts that are still part of Windows. But it was already bad practice to use ISE even 10 years ago, as it has another execution environment than the normal PowerShell. This was the first thing I learned like 15 years ago and is also what Microsoft was confirming. – itpropro Jul 10 '23 at 22:28