Now we also need to understand how and the order that the policies are executed.
So, for example,
what happens if we have a Windows machine where we're pushing out a
policy using Group Policy to the machine itself,
but then we happen to have a user policy,
and we have a process policy?
What's the order that they would be executed?
Well, it's really easy.
So to begin with, it always looks at the current process,
so it'll start at the process.
So if we launch PowerShell, the actual PowerShell console,
tagging in a specific execution policy, that's what it will look for first.
If we just launch the PowerShell window without that,
then it will look at the current user.
So if there's a policy assigned, then that's what it will execute.
If we have no execution policy for the current user,
then it will go ahead and look at the local machine
policy that would be assigned.
If all of those fail and it can't identify a process policy,
a user or a machine policy, then it will default to restricted,
which is the standard block.
So what you'll find on a fresh, let's say, Windows 10 machine, you'll open up
the PowerShell window and try to execute a PowerShell script,
and it'll come back and say it's restricted because at that moment in time,
you have no process policy, no user policy, or no local machine policy.
So how do we actually retrieve the current execution policy precedence
order? Well, this is done in a single PowerShell command. We can use
Get‑ExecutionPolicy and then use the parameter of ‑List. This will then output what's available to us and what's been defined.