Enable PowerShell script execution in Windows lets you run scripts (.ps1 files) without errors like "Script execution is disabled." By default, this feature is disabled for security, but it’s essential for administrators and power users needing automation. The easiest way is via the Execution Policy—a built-in Windows feature that controls script runs. There’s no extra software needed, just a few command-line steps.
What You'll Need
- The Windows Command Prompt (Run as Administrator) – right-click Start, select "Windows Terminal (Admin)" or "Command Prompt (Admin)"
- Administrative privileges – running the command as a non-admin user will fail
- A script file (.ps1) if you're testing (optional)
- Windows PowerShell – available by default on all modern Windows versions (10/11 Pro/Enterprise)
Step-by-Step
- Open Command Prompt as Administrator: Press Win+X, then select "Windows Terminal (Admin)" or "Command Prompt (Admin)" from the menu. If prompted, click "Yes" to confirm admin rights.
- Check current execution policy: Type this command to see which policy is active:
Get-ExecutionPolicyCommon results are: -Restricted(default, blocks all script execution) -AllSigned(runs only unsigned scripts) -RemoteSigned(allows local scripts, requires online verification) -Unrestricted(full script execution) Labels can differ slightly by Windows version and region. - Set a new execution policy: Use one of these commands based on your needs:
-
Set-ExecutionPolicy RemoteSigned(recommended for most users – allows local scripts, verifies online) -Set-ExecutionPolicy Unrestricted(full access, only for trusted environments) -Set-ExecutionPolicy RemoteSigned -Scope CurrentUser(only affects your user profile) Warning: Changing toUnrestrictedremoves security restrictions but enables any script, including malicious ones. Only use this in trusted environments. - Confirm the change: Run
Get-ExecutionPolicyagain to verify the new setting. - Test script execution: If you have a test script (.ps1 file), navigate to its folder using
cd "path\to\script"then run:powershell -ExecutionPolicy RemoteSigned -File script.ps1For the defaultRemoteSignedsetting, just runpowershell script.ps1in the same directory.
Common Mistakes
- Forgetting to run the command as Administrator: Script execution requires elevated permissions. If you get an error, try running Command Prompt as admin again. - Using the wrong scope: The policy change only applies to your current user session unless you use-Scope CurrentUser or -Scope Process. Restart PowerShell to apply changes.
- Mixing execution policies: Always use Get-ExecutionPolicy to check current settings before setting a new one.
- Checking the wrong directory: The script must be in the current working directory when you run it, or use full paths like C:\path\to\script.ps1.
Tips
- For remote servers: UseSet-ExecutionPolicy RemoteSigned -Scope Process inside PowerShell to run a single script without changing the global policy.
- To revert to Restricted: Use Set-ExecutionPolicy Restricted (requires admin rights).
- Use powershell -ExecutionPolicy Bypass -File script.ps1 to bypass policy for a single script—useful for one-off tasks but not recommended for automation.
- Always verify scripts from trusted sources when using Unrestricted mode.
Troubleshooting
If the command fails with an error like "Access is denied," you must: 1. Run the entire command prompt as Administrator (Step 1). 2. Ensure you're runningpowershell.exe, not the Windows Script Host (cscript.exe) or other tools.
3. If using a script, double-check the file extension is .ps1 (not .txt or .cmd) and the path is correct.
If Set-ExecutionPolicy fails with "The Security Configuration is not set," try:
- Close and reopen PowerShell
- Run
Set-ExecutionPolicy -ExecutionPolicy RemoteSignedagain - If still stuck, use
powershell -ExecutionPolicy Bypass -Command "Set-ExecutionPolicy RemoteSigned"(temporary workaround)
Frequently Asked Questions
Why does PowerShell block script execution by default?
Windows security blocks script execution to prevent unauthorized code execution, malware, and data theft. TheExecution Policy acts as a safeguard.
What happens if I set the policy to Unrestricted?
Any script will execute, including unsigned or potentially harmful scripts. This is only recommended for trusted environments like local development machines with minimal risk.
How do I check which scripts are currently running?
UseGet-Process powershell to verify PowerShell is running, then check Get-Process | Where-Object { $_.Path -like "*powershell*" } to list open PowerShell instances.
Can I disable the execution policy for a single script?
Yes, usepowershell -ExecutionPolicy Bypass -File script.ps1 to bypass the policy for that one run. For automation, set RemoteSigned or Unrestricted instead.
What if I get an error like "Script execution is disabled on this system" when trying to run a script?
This means your execution policy is set toRestricted or AllSigned. Use Set-ExecutionPolicy RemoteSigned (as shown in Step 3) to enable local script execution.
How do I remove a script from my execution policy history?
The execution policy doesn’t track scripts—it only manages permission settings. If you’re concerned about past scripts, audit your system for suspicious activity instead.Why won’t my script run even after setting the policy?
Check these common causes: - The script has a different extension (e.g., .txt). - You’re using the wrong command (e.g.,cscript script.ps1 instead of PowerShell).
- The script contains errors or syntax issues.
- Your antivirus is blocking PowerShell scripts (try disabling it temporarily).