PowerShell Logo Small


This is the built-in help made by Microsoft for the command 'Get-ExecutionPolicy', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.


Gets the execution policies for the current session.


Get-ExecutionPolicy [[-Scope] <ExecutionPolicyScope>] [-List] [<CommonParameters>]

Search powershellhelp.space


The Get-ExecutionPolicy cmdlet gets the execution policies for the current session.

The execution policy is determined by execution policies that you set by using Set-ExecutionPolicy and the Group Policy settings for the Windows PowerShell execution policy.
The default value is "Restricted."

Without parameters, Get-ExecutionPolicy gets the execution policy that is effective in the session. You can use the List parameter to get all execution policies that affect
the session or the Scope parameter to get the execution policy for a particular scope.

For more information, see about_Execution_Policies (http://go.microsoft.com/fwlink/?LinkID=135170).



Online Version: http://go.microsoft.com/fwlink/p/?linkid=293937




-------------------------- EXAMPLE 1 --------------------------

PS C:\>Get-ExecutionPolicy

This command gets the current execution policy for the computer.

-------------------------- EXAMPLE 2 --------------------------

PS C:\>Set-ExecutionPolicy RemoteSigned
PS C:\>Get-ExecutionPolicy

These commands set a new user preference for the execution policy and then display the effective execution policy. The commands are separated by a semicolon (;). In this
example, because there is no Group Policy setting, the user preference is the effective policy for the computer.

-------------------------- EXAMPLE 3 --------------------------

PS C:\>Get-ExecutionPolicy -list

Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser AllSigned
LocalMachine RemoteSigned

PS C:\>Get-ExecutionPolicy

These commands get all execution policies in the current session and the effective execution policy.

The first command gets all execution policies that affect the current session. The policies are listed in precedence order.

The second command gets only the effective execution policy, which is the one set in the CurrentUser scope.

-------------------------- EXAMPLE 4 --------------------------

The first command uses the Get-ExecutionPolicy cmdlet to get the effective execution policy in the current session.
PS C:\>Get-ExecutionPolicy

The second command shows what happens when you run a blocked script in a Windows PowerShell session in which the execution policy is RemoteSigned. The RemoteSigned policy
prevents you from running scripts that are downloaded from the Internet unless they are digitally signed.
PS C:\>.\Start-ActivityTracker.ps1

.\Start-ActivityTracker.ps1 : File .\Start-ActivityTracker.ps1 cannot be loaded. The file .\Start-ActivityTracker.ps1 is not digitally signed. The script will not execute on
the system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ .\Start-ActivityTracker.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess

The third command uses the Unblock-File cmdlet to unblock the script so it can run in the session.Before running an Unblock-File command, read the script contents and verify
that it is safe.
PS C:\>Unblock-File -Path Start-ActivityTracker.ps1

This command shows the effect of the Unblock-File command. The command does not change the execution policy. However, it unblocks the script so it will run in Windows
PS C:\>Get-ExecutionPolicy
PS C:\>Start-ActivityTracker.ps1
Task 1:

This example shows the effect of the RemoteSigned execution policy, which prevents you from running unsigned scripts that were downloaded from the Internet. It also shows
how to use the Unblock-File cmdlet to unblock scripts, so that you can run them without changing the execution policy.