5.1 KiB
How to Fix "Running Scripts is Disabled on this System" in PowerShell
PowerShell is blocking your script due to its execution policy settings, which are in place for security reasons. You can change these settings easily to allow your script to run.
Recommended Steps
- Open PowerShell as Administrator
- Click Start, search for PowerShell.
- Right-click and select Run as Administrator.
- Check Current Execution Policies
- Run:
Get-ExecutionPolicy -List
- This displays the policies for each scope (see table below for explanations).
- Unblock Script Execution for Your User
- To allow scripts for your user only (safest):
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
- *RemoteSigned* allows scripts you write and scripts downloaded from the internet if they are signed.
- If You Need to Allow All Scripts (Less Secure)
- Run:
Set-ExecutionPolicy Unrestricted -Scope CurrentUser
- This will allow any script to run, regardless of source. Use only if you trust the scripts you’re executing.
- Confirm Security Prompts
If You Still Get the Error (Group Policy Enforced)
If changing the execution policy doesn’t work, your system might have a Group Policy overriding this setting:
- Press
Win + R, typegpedit.msc, and press Enter. - Navigate to:
Local Computer Policy > Computer Configuration > Administrative Templates > Windows Components > Windows PowerShell
- Double-click Turn on Script Execution.
- Set it to Enabled and choose Allow all scripts (or less permissive option if desired)1 4 .
Execution Policy Scopes Explained
| Scope | Description |
|---|---|
| MachinePolicy | Enforced by Group Policy for entire machine |
| UserPolicy | Enforced by Group Policy for current user |
| Process | Applies only to current PowerShell session |
| CurrentUser | Applies to scripts run by current Windows user |
| LocalMachine | Applies to all users on the computer |
Execution policies set at higher scopes (MachinePolicy, UserPolicy) override lower scopes (CurrentUser, LocalMachine)5 .
Quick Troubleshooting
- If only running a script once, you can bypass the policy by running:
powershell -ExecutionPolicy Bypass -File .\mainscript.ps1
- Use
RemoteSignedorUnrestrictedmindfully, as they lower script execution restrictions.
Note: Always revert your execution policy to the original or a safer state (such as Restricted) after running untrusted or experimental scripts for security6 5 .
References: Information sourced directly from Microsoft documentation and community troubleshooting discussions1 2 5 3 .
-
https://stackoverflow.com/questions/4037939/powershell-says-execution-of-scripts-is-disabled-on-this-system ↩︎
-
https://www.addictivetips.com/windows-tips/fix-running-scripts-is-disabled-on-this-system-powershell-on-windows-10/ ↩︎
-
https://techpress.net/powershell-running-scripts-is-disabled-on-this-system-error/ ↩︎
-
https://learn.microsoft.com/en-us/answers/questions/506985/powershell-execution-setting-is-overridden-by-a-po ↩︎
-
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.5 ↩︎