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 ...
Get SQL Server 2014 with PowerShell v5 Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.