1
00:00:01,040 --> 00:00:05,450
So next, let me show you real briefly how to work with command history.

2
00:00:05,450 --> 00:00:06,100
Now, you see,

3
00:00:06,100 --> 00:00:11,350
I have run a bunch of commands, and I can use the up arrow key and

4
00:00:11,350 --> 00:00:16,540
cycle through and find the commands that I ran before.

5
00:00:16,540 --> 00:00:18,100
And if I find something I want,

6
00:00:18,100 --> 00:00:25,140
I can just hit Enter and rerun that command. Get‑history, if I type it right,

7
00:00:25,140 --> 00:00:30,040
will show me all of the commands, and there you can see the history

8
00:00:30,040 --> 00:00:35,270
ID. You can scroll up to see all the commands.

9
00:00:35,270 --> 00:00:36,090
Now,

10
00:00:36,090 --> 00:00:40,810
these history items will only last for as long as your PowerShell session

11
00:00:40,810 --> 00:00:45,340
is running, and there is a limit to what you can see.

12
00:00:45,340 --> 00:00:48,930
There was a variable called $MaximumHistoryCount, and just

13
00:00:48,930 --> 00:00:53,200
so you know there, I just typed $Max and then hit Tab and

14
00:00:53,200 --> 00:00:55,280
it auto‑completed that value.

15
00:00:55,280 --> 00:00:59,930
That's something you want to get in the habit of doing in PowerShell.

16
00:00:59,930 --> 00:01:07,930
So, by default, my PowerShell session will maintain a history list of 4096 items.

17
00:01:07,930 --> 00:01:15,320
Once they hit 4097, the oldest item is deleted and the next item then moves up.

18
00:01:15,320 --> 00:01:19,770
You can adjust that variable if you need to make it larger or

19
00:01:19,770 --> 00:01:23,040
smaller. So you can do the up and down arrows.

20
00:01:23,040 --> 00:01:25,140
You can use the history command.

21
00:01:25,140 --> 00:01:30,520
So if I want to say, what did I have here in history line item 10? All right,

22
00:01:30,520 --> 00:01:33,440
that was running Get‑Verb ‑more.

23
00:01:33,440 --> 00:01:42,990
If I want to run that, I can do r 10, and that then reruns that command.

24
00:01:42,990 --> 00:01:44,320
Now, what is r?

25
00:01:44,320 --> 00:01:44,710
Well,

26
00:01:44,710 --> 00:01:52,140
let's do get‑alias r. That resolves to Invoke‑History.

27
00:01:52,140 --> 00:01:54,460
If I do get, because I showed you h,

28
00:01:54,460 --> 00:01:59,940
let's do get‑alias h, and you can see that resolves to Get‑History.

29
00:01:59,940 --> 00:02:09,000
So that is one way that we can look at history using the history cmdlets and the up and down arrows.

