Powershell PSReadLine 历史记录

Cha*_*ler 4 powershell

我对 Powershell 中的跨会话历史记录如何工作感到困惑PSReadLine。我可以看到在 PS 版本 5.1 中我以前的命令历史记录自动存储在

%userprofile%\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\
Run Code Online (Sandbox Code Playgroud)

但是,如果我运行,get-history我只能看到当前的会话命令历史记录。我认为在更高版本的 Powershell 中不再需要用于跨会话保存命令历史记录的钩子。我缺少什么?

小智 9

文件

%userprofile%\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt
Run Code Online (Sandbox Code Playgroud)

仅包含输入的命令(此处为 ATM 22k 行),

以及当前会话历史记录

Get-History | Format-List -Property *
Run Code Online (Sandbox Code Playgroud)
Id                 : 88
CommandLine        : get-help Get-History -online
ExecutionStatus    : Completed
StartExecutionTime : 2018-12-14 16:16:49
EndExecutionTime   : 2018-12-14 16:16:49
Run Code Online (Sandbox Code Playgroud)

是完全不同的事情。