Contact Info

Crumbtrail » Administration » Powershell » Powershell 1.0 » Get-History

Get-History - Powershell 1.0 CmdLet

ActiveXperts Network Monitor ships with integrated Powershell scripts to monitor complex network. The scripts run out of the box
Download the ActiveXperts Network Monitor FREE version now »


Get a listing of the session history

Get-History [ [-count] int ]
        [ [-id] long[] ]

        Display n of most-recent history entries.
        The default is 32. 

   -id  The ID number of a command in the session history.
	     Get-History gets only the specified command. 

       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutVariable.

Get the (32) most recent entries from the session history, and pipe the results to the Where-Object to select only commands that include "service":

PS C:\>get-history | where-object {$_.commandLine -like "*service*"}

Display the properties of entries in the session history:

PS C:\>get-history | format-list

Get the 50 most recent entries from the session history and pipe the result to to Export-Csv, saving it as a comma-separated text file:

PS C:\>get-history -count 50 | export-csv history.csv