PowerShell for Windows Admins

Jul 24 2014   2:22PM GMT

History cmdlets

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

There are 4 cmdlets for working with the history in a PowerShell session:

Add-History – adds an entry to the history
Clear-History – clears the history
Get-History -enables you see the current history
Invoke-History – enables you to run a line in your history

Get-History is the one I use the most.  You can use the UP arrow key to cycle back to an old command or use Invoke-History.

I’d only use Clear-History if I had a long running session and I was changing what I was working on.

Add-History is the odd one. I’ve never used it but it could be useful if you have a command you run often and you want to push it into the history when you start a session.

Be aware of  a  variable that controls history:

$MaximumHistoryCount  defaults to  4096 and is the maximum number of commands saved in the command history.

You can increase this up to 32768 if you desire but unless you put the command in your profile your next session will drop back to the default.

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: