How can I see the command history across all PowerShell sessions in Windows Server 2016?

后端 未结 2 1928
醉梦人生
醉梦人生 2020-12-12 16:14

Where can you view the full history from all sessions in Windows Server 2016?

The following PowerShell command only includes the commands from the current session:

相关标签:
2条回答
  • 2020-12-12 16:37

    The Psreadline module 2.1 beta1 on Powershell gallery (Powershell 7 only) https://www.powershellgallery.com/packages/PSReadLine/2.1.0-beta1 does intellisense on the commandline using the saved history: https://github.com/PowerShell/PSReadLine/issues/1468 It's been starting to show up in Vscode. https://www.reddit.com/r/PowerShell/comments/g33503/completion_on_history_in_vscode/

    Also in Psreadline, you can search the saved history backwards with either f8 (after typing something on the command line) or control-R. Get-psreadlinekeyhandler lists the key bindings.

    get-psreadlinekeyhandler -bound -unbound | ? function -match history
    
    0 讨论(0)
  • 2020-12-12 16:52

    In PowerShell enter the following command:

    (Get-PSReadlineOption).HistorySavePath
    

    This gives you the path where all of the history is saved. Then open the path in a text editor.

    Try cat (Get-PSReadlineOption).HistorySavePath to list the history in PowerShell.

    0 讨论(0)
提交回复
热议问题