在哪里可以查看 Windows Server 2016 中所有会话的完整历史记录?
以下 PowerShell 命令仅包含当前会话中的命令:
Get-History
在 PowerShell 中输入以下命令:
(Get-PSReadlineOption).HistorySavePath
这为你提供了保存所有历史记录的路径。然后在文本编辑器中打开路径。
尝试cat (Get-PSReadlineOption).HistorySavePath
在 PowerShell 中列出历史记录。
实际上,它在全新安装的 Windows Server 2016 中默认存在。
它在我的 Windows 10 Pro (1703) 中。但我不知道它是否默认存在,或者是否有 Visual Studio 或其他类似工具安装的某个模块。尽管如此,在我迟到的蓝屏之后,它还是帮助了我。
默认情况下,它在 Windows 10 Enterprise 64 位上存在。
基本上简单
cat (Get-PSReadlineOption).HistorySavePath
地使用来获取整个历史。谢谢@DanielLeach使用
cat (Get-PSReadlineOption).HistorySavePath | select -Last 10
得到的最后10行。如果您的历史记录中有许多命令,则很有用。