Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何查看Windows Server 2016中所有PowerShell会话的命令历史记录?_Powershell_Windows Server 2016 - Fatal编程技术网

如何查看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

在哪里可以查看Windows Server 2016中所有会话的完整历史记录

以下PowerShell命令仅包括来自当前会话的命令:

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
即可获取整个历史。谢谢@Daniellachue
cat(获取PSReadlineOption)。HistorySavePath |选择-Last 10
获取最后10行。如果历史记录中有多个命令,则此选项非常有用。