1
00:00:00,140 --> 00:00:02,240
So now that we have the scripts created,

2
00:00:02,240 --> 00:00:06,840
how do we execute scripts within the PowerShell console?

3
00:00:06,840 --> 00:00:07,080
Well,

4
00:00:07,080 --> 00:00:10,540
the common PowerShell consoles we talked about were

5
00:00:10,540 --> 00:00:12,450
the Windows PowerShell console,

6
00:00:12,450 --> 00:00:15,700
the Windows Terminal, and then we have Visual Studio Code,

7
00:00:15,700 --> 00:00:17,790
and we also have one that still hangs around,

8
00:00:17,790 --> 00:00:21,440
which is called the PowerShell Integrated Development Environment,

9
00:00:21,440 --> 00:00:24,640
and you'll see that listed in your Windows machines.

10
00:00:24,640 --> 00:00:27,500
Now, people tend to shy away from that one because that may

11
00:00:27,500 --> 00:00:30,940
not be around for much longer, but at least the first three

12
00:00:30,940 --> 00:00:33,440
are going to be consistent.

13
00:00:33,440 --> 00:00:35,240
So how do we execute the scripts?

14
00:00:35,240 --> 00:00:40,440
Well, first off, we need to ensure the execution policy is set as you require.

15
00:00:40,440 --> 00:00:43,320
Now, you don't have to set this to anything specific.

16
00:00:43,320 --> 00:00:46,580
It's up to you. Often for testing, I'll just say Unrestricted,

17
00:00:46,580 --> 00:00:51,840
which isn't the best because it means I can do whatever, but choose that wisely.

18
00:00:51,840 --> 00:00:54,450
We can then type the ampersand,

19
00:00:54,450 --> 00:00:58,170
followed by the path to the script file for execution.

20
00:00:58,170 --> 00:01:00,130
That's an easy way of actually doing it.

21
00:01:00,130 --> 00:01:05,470
We then press Enter and then wait for that script to complete. Now,

22
00:01:05,470 --> 00:01:08,140
to execute the scripts within Visual Studio Code,

23
00:01:08,140 --> 00:01:13,800
which I really enjoy, the console and the editor are integrated to each other,

24
00:01:13,800 --> 00:01:15,930
so you can simply load it,

25
00:01:15,930 --> 00:01:21,600
load the PowerShell file, and then press F5 to execute that entire script,

26
00:01:21,600 --> 00:01:23,530
which will execute in the bottom section,

27
00:01:23,530 --> 00:01:25,450
which will be the integrated console.

28
00:01:25,450 --> 00:01:30,610
You also have the ability to select specific lines and

29
00:01:30,610 --> 00:01:32,540
right‑click and just say Execute.

30
00:01:32,540 --> 00:01:37,280
So I really enjoy that kind of idea because it means I have a great

31
00:01:37,280 --> 00:01:41,140
editor, and I can see the script being executed.

32
00:01:41,140 --> 00:01:44,410
We can also use the PowerShell IDE that's available.

33
00:01:44,410 --> 00:01:47,540
So this is the integrated console and editor.

34
00:01:47,540 --> 00:01:56,000
You also can press F5 to execute an entire script, as well as selecting specific lines to execute as well.

