Powershell - Playing with command history
To support me, you can subscribe to the channel, share and like the videos, disable your ad blocker or make a donation. Thank you!
Hello,
If you use Powershell regularly, it can be interesting to know how to use the history or rather the histories:
- Powershell history (in the current Shell Get-History)
- PSReadLine module history (stored in a file by default)
- The Powershell console cache (command recall with arrows or F8).
Powershell has a command history (default 50).
You can use the up and down arrows to quickly display them.
## Powershell history# Display a list of commands used in the current session.Get-History
# Reuse a command from the historyInvoke-History -Id 33
# Export historyGet-History | Export-CSV -Path 'C:\Temp\History.CSV'
# Import history$History = Import-Csv -Path 'C:\Temp\History.Csv' # Add-History -InputObjectAdd-History -InputObject $History
# Clear historyClear-History
# Delete the last commandClear-History -count 1 -newest
## History PSReadLine# Search the history based on the first characters of the F8 commandC<F8># F8 as many times as necessary (Shift + F8 to go back)# You can use F8 directly without specifying any characters
# Search the history using CTRL + R (backwards), CTRL + S (forwards) command matchesCTRL + Renter the word containing the command you are looking for> Enter
# Launch the last command in the history starting with (thanks to the #)#get# Does not work in PowerShell 7
# List the keyboard shortcuts in the historyGet-PSReadlineKeyHandler | Where-Object {$_.function -like '*hist*'}
Complete your reading with the following articles:
Improving Powershell command-line usability with PSReadLine
PowerShell - Command history and confidential information
Related links
Powershell - Testing network connectivity and port accessibility
Testing network connectivity and port accessibility with PowershellPowershell - Display network connections (equivalent to netstat)
Display network connections (listening ports, active connections...)Powershell - Testing name resolution (equivalent to nslookup)
Powershell commands to test name resolution (equivalent to nslookup)Powershell - View and manage DNS configuration of network interfaces
Powershell commands to display and manage DNS configuration of network interfacesPowershell - Managing IP configuration of network interfaces
Powershell commands to view and modify the IP configuration of network interfacesPowershell - Managing the status and configuration of network interfaces
Powershell commands to view and modify the status and configuration of network interfaces (disable IPv6, enable/disable an interface)
Follow me on
Support me
Last content
Powershell - Testing network connectivity and port accessibility
Powershell - Display network connections (equivalent to netstat)
Powershell - Testing name resolution (equivalent to nslookup)
Powershell - View and manage DNS configuration of network interfaces
Powershell - Managing IP configuration of network interfaces
Powershell - Managing the status and configuration of network interfaces
Powershell and the Left Hand Side
Powershell - Managing disks, partitions and volumes