Fix 'Running Scripts Is Disabled' Error in PowerShell
In this article
If you've ever tried to run a PowerShell script and hit the error "running scripts is disabled on this system", you're dealing with PowerShell's execution policy. This safety feature blocks scripts from running by default to prevent malicious code execution. This guide walks you through the steps to safely enable script execution, whether for the current user or the entire system, and covers common pitfalls and troubleshooting.
What You'll Need
- Windows 10 or Windows 11 (or Windows Server 2016+).
- Administrator access (for changing system-wide policies).
- PowerShell (any version, including PowerShell 7).
Step-by-Step
- Open PowerShell as Administrator. Right-click the Start button and select "Windows PowerShell (Admin)" or "Terminal (Admin)" from the menu. If you're not an admin, you can still change the policy for your current user only, but the steps below for system-wide changes require admin rights.
- Check the current execution policy. Type
Get-ExecutionPolicyand press Enter. It will likely showRestricted(the default on most systems). - Choose the right execution policy. The most common options are:
RemoteSigned– Allows local scripts to run, but scripts downloaded from the internet must be digitally signed. This is the recommended balance for most users.AllSigned– Requires all scripts (local and downloaded) to be signed by a trusted publisher.Unrestricted– Runs all scripts, but warns before running downloaded files. Not recommended for security.Bypass– Runs everything without any warnings. Only for temporary use.
- Set the execution policy for the current user only. If you don't have admin rights or want to limit the change to your account, run:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Confirm withYwhen prompted. - Set the execution policy for the entire system (requires admin). In the admin PowerShell window, run:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
Again, confirm withY. - Verify the change. Run
Get-ExecutionPolicy -Listto see the effective policy for all scopes. The output shows which policy applies to your current session. - If you're still getting the error, try bypassing for a single script. Instead of changing the policy, you can run a script with the bypass flag:
powershell -ExecutionPolicy Bypass -File "C:\path\to\script.ps1"
Or in PowerShell itself:powershell -ExecutionPolicy Bypass -File .\script.ps1
- If the script is downloaded from the internet, unblock it. Right-click the file in File Explorer, select Properties, and check the "Unblock" box if it appears. Then try running it again.
Common Mistakes
- Setting the policy without admin rights. If you try to change the
LocalMachinescope without admin, you'll get an access denied error. UseCurrentUserinstead. - Using the wrong scope. If you set the policy for
CurrentUserbut the script is run under a different user (like a service), it won't apply. CheckGet-ExecutionPolicy -Listto see all scopes. - Forgetting to restart PowerShell. Some changes might not take effect until you close and reopen the PowerShell window.
- Typing the command incorrectly. Make sure you use
Set-ExecutionPolicywith proper capitalization and no typos. Use tab completion to avoid mistakes.
Tips
- Use
RemoteSignedas your default. It's secure enough for most users and lets you run your own scripts without signing them. - Check the effective policy with
Get-ExecutionPolicy -List. This shows the policy for each scope, and the effective one is the most restrictive among them. - If you're running scripts from a network share, they may be treated as "remote" and require signing. You can use
Unblock-Fileon them if they're copied locally. - For one-off scripts, the
-ExecutionPolicy Bypassflag is a quick workaround without changing your system settings.
Troubleshooting
- Error: "Access to the registry key is denied." This means you're not running as administrator. Close and reopen PowerShell as admin, or use the
CurrentUserscope. - Error: "The execution policy setting "RemoteSigned" is not recognized." Double-check the spelling. Valid values are
Restricted,AllSigned,RemoteSigned,Unrestricted,Bypass, andUndefined. - Policy is set but still getting the error. Check if a Group Policy is overriding your setting. Run
gpresult /h gp.htmland look for "PowerShell Execution Policy" under Computer or User Configuration. If it's set there, you need to change it via Group Policy Management, not PowerShell. - The script runs but is blocked by SmartScreen. If you downloaded the script from the internet, unblock it via File Properties or use
Unblock-File -Path .\script.ps1.
Frequently Asked Questions
What is the default execution policy in Windows?
On most Windows 10 and 11 systems, the default is Restricted for the LocalMachine scope, which blocks all scripts. Some systems may have RemoteSigned if the manufacturer set it.
Is it safe to set execution policy to Unrestricted?
It's not recommended. Unrestricted runs all scripts, including potentially malicious ones downloaded from the internet, without any warnings. Use RemoteSigned instead – it allows local scripts and only requires downloaded scripts to be signed.
How do I revert to the default policy?
Run Set-ExecutionPolicy -ExecutionPolicy Restricted -Scope CurrentUser (or LocalMachine if you changed that). This restores the default blocking behavior.
Can I run a single script without changing the policy?
Yes, use the -ExecutionPolicy Bypass flag when launching PowerShell: powershell -ExecutionPolicy Bypass -File script.ps1. This overrides the policy for that one command only.
Why does my script work in ISE but not in PowerShell console?
ISE and console may have different execution policies. Check with Get-ExecutionPolicy in both. You can set the policy for CurrentUser to apply to both.
Does changing execution policy affect other users?
If you change the LocalMachine scope, it affects all users on the machine. If you change CurrentUser, it only affects your account. Use CurrentUser to avoid unintended consequences.