Scripting >> Powershell >> How to obtain the command history

To display command history

PS: C:\> Get-History

  Id CommandLine
  -- -----------
   1 help
   2 cd \
   3 cls

 

 

How to get more help on History

PS: C:\> help about_History

TOPIC
    about_History

SHORT DESCRIPTION
    Describes how to retrieve and run commands in the command history.


LONG DESCRIPTION
    When you enter a command at the command prompt, Windows PowerShell
    saves the command in the command history. You can use the commands
    in the history as a record of your work. And, you can recall and run the
    commands from the command history.


  History Cmdlets
      Windows PowerShell has a set of cmdlets that manage the command history.

          Cmdlet (Alias)       Description
          -------------------  ------------------------------------------
          Get-History (h)      Gets the command history.

          Invoke-History (r)   Runs a command in the command history.

          Add-History          Adds a command to the command history.

          Clear-History (clh)  Deletes commands from the command history.

....