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.