1
00:00:01,140 --> 00:00:03,570
As you run PowerShell commands in the console,

2
00:00:03,570 --> 00:00:07,440
you'll most likely find yourself rerunning earlier commands.

3
00:00:07,440 --> 00:00:10,540
Now, this doesn't mean that you have to be constantly typing.

4
00:00:10,540 --> 00:00:14,340
PowerShell has a command history that you can take advantage of.

5
00:00:14,340 --> 00:00:17,810
Easiest way is to use the up and down arrows to

6
00:00:17,810 --> 00:00:20,740
scroll through your command history.

7
00:00:20,740 --> 00:00:25,340
When you find what you want, stop, press Enter, and just rerun that command.

8
00:00:25,340 --> 00:00:29,440
Or you can make adjustments to the command and then run it.

9
00:00:29,440 --> 00:00:33,310
PowerShell also has a history cmdlet called Get‑History,

10
00:00:33,310 --> 00:00:36,240
which has an alias of h.

11
00:00:36,240 --> 00:00:38,080
And there's also Invoke‑History,

12
00:00:38,080 --> 00:00:41,680
which has an alias of r. Now, as you'll see in the demo, if

13
00:00:41,680 --> 00:00:45,730
you know the history ID, you can easily rerun a command with

14
00:00:45,730 --> 00:00:47,550
Invoke‑History or its alias.

15
00:00:47,550 --> 00:00:50,640
I do this all the time in my PowerShell work.

16
00:00:50,640 --> 00:00:55,160
The built‑in PSReadline module also has history‑searching capabilities,

17
00:00:55,160 --> 00:00:59,440
which will be easier to demo than to try to explain here in a slide.

18
00:00:59,440 --> 00:01:01,240
And then also, when I get to the demo,

19
00:01:01,240 --> 00:01:05,050
I'm going to show you a new feature, at least new as the time I'm

20
00:01:05,050 --> 00:01:09,620
recording this course, that uses your history that we have with

21
00:01:09,620 --> 00:01:13,640
PSReadline to predict the command that you want to run.

22
00:01:13,640 --> 00:01:15,280
Once you get the hang of these features,

23
00:01:15,280 --> 00:01:22,000
you'll find it much easier and quicker to work in PowerShell without having to retype everything.

