Getting history
You can recall the commands you typed in the PowerShell console using the Get-History
cmdlet.
How to do it...
This is how to redisplay the console history:
- Open PowerShell ISE as an administrator.
- Run the following command:
Get-History
How it works...
By default, PowerShell will keep 64 previous commands in the buffer and allow you to recall these commands when you run Get-History
. The Get-History
command will display the last 32 commands, but you can also specify how many lines you want to display by specifying the –Count
parameter:
#get last 10 Get-History –Count 10
If you want to reexecute any of the commands that you see in your history, you can use the Invoke-History
cmdlet and provide it with the history ID. For example, if you want to re-execute ID 7, you can use the following command:
Invoke-History –ID 7