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

  1. 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.
  2. Check current execution policy: Type this command to see which policy is active: Get-ExecutionPolicy Common 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.
  3. 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 to Unrestricted removes security restrictions but enables any script, including malicious ones. Only use this in trusted environments.
  4. Confirm the change: Run Get-ExecutionPolicy again to verify the new setting.
  5. 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.ps1 For the default RemoteSigned setting, just run powershell script.ps1 in 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: Use Set-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 running powershell.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:
  1. Close and reopen PowerShell
  2. Run Set-ExecutionPolicy -ExecutionPolicy RemoteSigned again
  3. If still stuck, use powershell -ExecutionPolicy Bypass -Command "Set-ExecutionPolicy RemoteSigned" (temporary workaround)
For persistent issues after policy changes: - Restart the computer. - Reboot the session by logging out and back in to PowerShell. - Check for conflicting antivirus software that might block scripts (temporarily disable it for testing).

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. The Execution 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?

Use Get-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, use powershell -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 to Restricted 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).