如何查看Windows Server 2016中所有PowerShell会话的命令历史记录?
在哪里可以查看Windows Server 2016中所有会话的完整历史记录 以下PowerShell命令仅包括来自当前会话的命令:如何查看Windows Server 2016中所有PowerShell会话的命令历史记录?,powershell,windows-server-2016,Powershell,Windows Server 2016,在哪里可以查看Windows Server 2016中所有会话的完整历史记录 以下PowerShell命令仅包括来自当前会话的命令: Get-History 在PowerShell中输入以下命令: (Get-PSReadlineOption).HistorySavePath 这将为您提供保存所有历史记录的路径。然后在文本编辑器中打开路径 请尝试cat(获取PSReadlineOption)。HistorySavePath列出PowerShell中的历史记录。PowerShell galler
Get-History
在PowerShell中输入以下命令:
(Get-PSReadlineOption).HistorySavePath
这将为您提供保存所有历史记录的路径。然后在文本编辑器中打开路径
请尝试
cat(获取PSReadlineOption)。HistorySavePath
列出PowerShell中的历史记录。PowerShell gallery上的Psreadline模块2.1 beta1(仅限PowerShell 7)使用保存的历史记录在命令行上执行intellisense:它已开始在Vscode中显示
同样在Psreadline中,您可以使用f8(在命令行上键入内容后)或control-R向后搜索保存的历史记录。Get-psreadlinekeyhandler列出键绑定
get-psreadlinekeyhandler -bound -unbound | ? function -match history
看历史
cat (Get-PSReadlineOption).HistorySavePath
使用此cmd将此历史记录保存在文件中
cat (Get-PSReadlineOption).HistorySavePath | Out-File -FilePath History.csv
事实上,它在Windows Server 2016的新安装中默认存在。它在我的Windows 10 Pro(1703)中。但我不知道默认情况下是否有,或者是否有VisualStudio或其他类似工具安装的模块。尽管如此,它还是帮助了我,在我最新的蓝屏之后。它在Windows 10 Enterprise 64位上默认存在。基本上只需使用
cat(Get-PSReadlineOption)。HistorySavePath
即可获取整个历史。谢谢@Daniellachuecat(获取PSReadlineOption)。HistorySavePath |选择-Last 10
获取最后10行。如果历史记录中有多个命令,则此选项非常有用。