【发布时间】:2013-07-25 14:49:20
【问题描述】:
我尝试使用命令加载我的 PowerShell 历史记录
Import-Clixml ~\history.clixml | Add-History
在我的 $profile 中。
我还编写了一个自定义退出函数来保存它们:
function global:xx
{
Get-History | Export-Clixml ~\history.clixml
exit
}
我键入“xx”退出 PowerShell,然后重新启动 PowerShell。虽然它加载我的history.clixml 没有任何错误,但当我单击向上箭头键时,我没有看到任何命令显示。这个键通常可以让我从我的命令历史中访问我以前的命令。
【问题讨论】:
-
我没有找到“history.clixml”文件,但有一个位置,由
(Get-PSReadlineOption).HistorySavePath(例如C:\Users\giraf\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt)获得,其中包含此类信息。见How can I see the command history across all PowerShell sessions in Windows Server 2016?。
标签: windows powershell