Set-ExecutionPolicy changes PowerShell's execution policy, which controls whether scripts can run. On Windows 10, the default Restricted setting allows interactive commands but blocks scripts. section 4.1.1
Check before changing
Run Get-ExecutionPolicy to view the current setting. Run Set-ExecutionPolicy to change the local policy; changing the machine-wide registry setting usually requires administrator privileges. section 4.1.1
Account for the available policy mechanisms:
- Set-ExecutionPolicy changes the setting in the local machine portion of the Windows Registry. section 4.1.1
- A Group Policy Object overrides the local setting, so Set-ExecutionPolicy may report that its change had no effect. section 4.1.1
- PowerShell.exe -ExecutionPolicy can override both local and Group Policy settings for that invocation. section 4.1.1
Use the representative error to recognize when a disabled execution policy prevents a script from loading. section 4.1.1
