By default, Windows PowerShell restricts the execution of scripts for security reasons. This prevents unauthorized scripts from running and potentially harming your system. However, if you’re a developer or system administrator who needs to automate tasks, you’ll often need to enable script execution in PowerShell.
In this guide, we’ll show you step-by-step how to enable script execution on Windows 11 safely, explain what the different execution policies mean, and how to revert the changes if needed.
Why PowerShell Blocks Scripts by Default
PowerShell uses an Execution Policy setting to determine which scripts can run on your system. This helps protect your PC from malicious or unverified scripts. The most restrictive policy is Restricted, which prevents all scripts from running — even ones you write yourself.
To run PowerShell scripts (.ps1 files), you’ll need to modify this policy to a less restrictive level, such as RemoteSigned or Unrestricted.
Check Your Current Execution Policy
Before enabling script execution, it’s good to check your current policy.
- Open PowerShell as Administrator.
- Run the following command:
Get-ExecutionPolicy - You’ll see one of these policies:
- Restricted – No scripts are allowed to run.
- AllSigned – Only scripts signed by a trusted publisher can run.
- RemoteSigned – Local scripts can run; downloaded scripts must be signed.
- Unrestricted – All scripts can run, but you’ll get a warning for remote ones.
Enable Script Execution in PowerShell
To enable PowerShell to run scripts, follow these steps:
- Open PowerShell as Administrator.
- Type the following command and press Enter:
Set-ExecutionPolicy RemoteSigned - When prompted, type Y and press Enter to confirm.
- You can verify the change by running:
Get-ExecutionPolicyYou should now see RemoteSigned.
Tip: The RemoteSigned policy is a good balance between security and functionality. It lets you run your own scripts while protecting your system from untrusted ones.
Temporarily Allow Script Execution (Per Session)
If you don’t want to change the global policy, you can enable script execution temporarily for the current PowerShell session.
Use this command:
PowerShell -ExecutionPolicy Bypass
This allows you to run scripts just once, and when you close PowerShell, the restriction returns to its default state. This is useful for testing scripts without altering your system settings.
Reverting to the Default Setting
If you ever want to disable script execution again, you can revert to the default Restricted policy.
Simply run:
Set-ExecutionPolicy Restricted
This ensures that no PowerShell scripts will run on your system unless explicitly allowed again.
Final Thoughts
Enabling script execution in PowerShell gives you the flexibility to automate tasks, run custom scripts, and improve productivity on Windows 11. Just remember to use a secure policy like RemoteSigned and avoid running unverified scripts from unknown sources.
By following these steps, you’ll have complete control over PowerShell’s script behavior — safely and effectively.