So now that we have the scripts created,
how do we execute scripts within the PowerShell console?
Well,
the common PowerShell consoles we talked about were
the Windows PowerShell console,
the Windows Terminal, and then we have Visual Studio Code,
and we also have one that still hangs around,
which is called the PowerShell Integrated Development Environment,
and you'll see that listed in your Windows machines.
Now, people tend to shy away from that one because that may
not be around for much longer, but at least the first three
are going to be consistent.
So how do we execute the scripts?
Well, first off, we need to ensure the execution policy is set as you require.
Now, you don't have to set this to anything specific.
It's up to you. Often for testing, I'll just say Unrestricted,
which isn't the best because it means I can do whatever, but choose that wisely.
We can then type the ampersand,
followed by the path to the script file for execution.
That's an easy way of actually doing it.
We then press Enter and then wait for that script to complete. Now,
to execute the scripts within Visual Studio Code,
which I really enjoy, the console and the editor are integrated to each other,
so you can simply load it,
load the PowerShell file, and then press F5 to execute that entire script,
which will execute in the bottom section,
which will be the integrated console.
You also have the ability to select specific lines and
right‑click and just say Execute.
So I really enjoy that kind of idea because it means I have a great
editor, and I can see the script being executed.
We can also use the PowerShell IDE that's available.
So this is the integrated console and editor.
You also can press F5 to execute an entire script, as well as selecting specific lines to execute as well.