Contact Info

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

Get-History - Powershell 1.0 CmdLet

Microsoft Windows PowerShell is a command-line shell and scripting tool based on the Microsoft .NET Framework. It is designed for system administrators, engineers and developers to control and automate the administration of Windows and applications.

More than hundred command-line tools (so called "cmdlets") can be used to perform system administration tasks and Windows Management Instrumentation (WMI). These cmdlets are easy to use, with standard naming conventions and common parameters, and standard tools for piping, sorting, filtering, and formatting data and objects.


Get a listing of the session history


        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