Welcome to Sign in | Join | Help
in
Home Blog Forums

The Lazy Admin

PowerShell History

Sponsor


Remember DOSKEY? Way back when .BAT files ruled the world, DOSKEY was used to enable you to recall and edit previously entered commands within the Command.exe (or CMD.exe). PowerShell takes this idea to the next level with the Get-History command.

By entering Get-History in MSH you will be shown a list of the most recent cmdlets that have been run.

You can get a more specific list of cmdlets run by piping "where {$_.commandLine -like "variable"}" This will display all cmdlets that have been run that match the variable, and wildcards are acceptable.

get-history | where {$_.commandLine -like "*process*"}

To run a cmdlet again, it is as simple as running the invoke-history cmdlet.

invoke-history [ID#]

The get-history cmdlet buffer will hold the last 64 commands run. You can increase this by running the following command.

$MaximumHistoryCount=#### (replace #### with the number of items)





Published Thursday, February 09, 2006 6:38 AM by rodney.buike
Filed under:

Comments

No Comments
Anonymous comments are disabled


All postings are provided "AS IS" with no warranties, and confer no rights.
Microsoft product screen shot(s) reprinted with permission from Microsoft Corporation.