CmdID / PowerShell / Cmdlets / Get
Get-ExecutionPolicy
Gets the execution policies for the current session. PowerShell reference
From the PowerShell reference 2 parameters
What it does
Gets the execution policies for the current session. To display the execution policies for each scope in the order of precedence, use Get-ExecutionPolicy -List. To see the effective execution policy for your PowerShell session use Get-ExecutionPolicy with no parameters. The effective execution policy is determined by execution policies that are set by Set-ExecutionPolicy and Group Policy settings. For more information, see about_Execution_Policies.
Get-ExecutionPolicy [[-Scope] <ExecutionPolicyScope>] [-List] [<CommonParameters>]
Get all execution policies
Get-ExecutionPolicy -ListIdentifySet an execution policy
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
Get-ExecutionPolicy -ListIdentifyGet the effective execution policy
PS> Get-ExecutionPolicy -List
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser AllSigned
LocalMachine RemoteSigned
PS> Get-ExecutionPolicy
AllSignedIdentifyUnblock a script to run it without changing the execution policy
PS> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
PS> Get-ExecutionPolicy
RemoteSigned
PS> .\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 https://go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ .\Start-ActivityTracker.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
PS> Unblock-File -Path .\Start-ActivityTracker.ps1
PS> Get-ExecutionPolicy
RemoteSigned
PS> .\Start-ActivityTracker.ps1
Task 1:IdentifyIts page in the reference: Get-ExecutionPolicy.
Parameters
-ListGets all execution policy values for the session. By default, Get-ExecutionPolicy gets only the effective execution policy.-ScopeSpecifies the scope that is affected by an execution policy.
The effective execution policy is determined by the order of precedence as follows:
- MachinePolicy. Set by a Group Policy for all users of the computer.
- UserPolicy. Set by a Group Policy for the current user of the computer.
- Process. Affects only the current PowerShell session.
- LocalMachine. Default scope that affects all users of the computer.
- CurrentUser. Affects only the current user.