首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >为什么PSReadLine历史文件丢失而PSReadLineOption AddToHistoryHandler在Powershell 5 ISE中为空白?

为什么PSReadLine历史文件丢失而PSReadLineOption AddToHistoryHandler在Powershell 5 ISE中为空白?
EN

Stack Overflow用户
提问于 2022-10-25 01:37:59
回答 1查看 31关注 0票数 2

在Powershell_ISE版本10.0.19041.1 (Windows10)宿主中运行Powershell 5.1.19041.1682时,将HistorySavePath属性设置为完整的文件路径,但是在ISE窗口中运行命令后从未创建该文件。我在ISE脚本窗格、输出窗格中执行命令,保存了一个ps1文件,关闭了ISE并重新打开。从未创建HistorySavePath文件。

在控制台主机中运行Powershell时,将创建由HistorySavePath属性(Consol eHost_history.txt)表示的文件,并将历史记录写入该文件。另外,(Get-PSReadLineOption).AddToHistoryHandler是为控制台主机填充的,而对于ISE则是空的。

为什么"Windows Host_history.txt“历史文件丢失,AddToHistoryHandler主机空白?

- ISE主机PSReadLine选项

代码语言:javascript
运行
复制
>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 

-控制台主机PSReadLine选项

代码语言:javascript
运行
复制
   >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
EN

Stack Overflow用户

发布于 2022-11-29 16:39:51

ISE多年来一直不受欢迎,您最好不要再使用它了,因为环境和几个cmdlet的行为不同,VSCode在linting、代码高亮化和使用现代PowerShell版本的7+方面要好得多。

票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74188327

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档