So next, let me show you real briefly how to work with command history.
Now, you see,
I have run a bunch of commands, and I can use the up arrow key and
cycle through and find the commands that I ran before.
And if I find something I want,
I can just hit Enter and rerun that command. Get‑history, if I type it right,
will show me all of the commands, and there you can see the history
ID. You can scroll up to see all the commands.
Now,
these history items will only last for as long as your PowerShell session
is running, and there is a limit to what you can see.
There was a variable called $MaximumHistoryCount, and just
so you know there, I just typed $Max and then hit Tab and
it auto‑completed that value.
That's something you want to get in the habit of doing in PowerShell.
So, by default, my PowerShell session will maintain a history list of 4096 items.
Once they hit 4097, the oldest item is deleted and the next item then moves up.
You can adjust that variable if you need to make it larger or
smaller. So you can do the up and down arrows.
You can use the history command.
So if I want to say, what did I have here in history line item 10? All right,
that was running Get‑Verb ‑more.
If I want to run that, I can do r 10, and that then reruns that command.
Now, what is r?
Well,
let's do get‑alias r. That resolves to Invoke‑History.
If I do get, because I showed you h,
let's do get‑alias h, and you can see that resolves to Get‑History.
So that is one way that we can look at history using the history cmdlets and the up and down arrows.