Enable Script Execution PowerShell: Step-by-Step
In this article
To enable script execution in PowerShell, you must change the execution policy using the Set-ExecutionPolicy cmdlet. The most common command is Set-ExecutionPolicy RemoteSigned, which allows locally created scripts to run while requiring downloaded scripts to be digitally signed.
What Is the PowerShell Execution Policy?
PowerShell's execution policy is a safety feature that controls the conditions under which PowerShell loads configuration files and runs scripts. It is not a security boundary that prevents malicious code from running; rather, it is designed to prevent users from accidentally executing scripts. The policy applies to the current user, the local machine, or a specific process, depending on how you set it.
There are several built-in policies:
- Restricted – No scripts can run. This is the default on most Windows client systems.
- AllSigned – All scripts must be signed by a trusted publisher.
- RemoteSigned – Locally created scripts run without a signature; scripts downloaded from the internet must be signed.
- Unrestricted – All scripts run, but you are warned before running downloaded files.
- Bypass – Nothing is blocked, and no warnings appear.
- Undefined – No policy is set for the scope; the effective policy is the one from the parent scope.
How to Check the Current Execution Policy
Before changing anything, see what policy is currently in effect. Open PowerShell (as administrator for machine-wide changes) and run:
Get-ExecutionPolicy
This shows the effective policy for the current session. To see all scopes, use:
Get-ExecutionPolicy -List
The output lists the policy for each scope (MachinePolicy, UserPolicy, Process, CurrentUser, LocalMachine). The effective policy is the one that applies – usually the most restrictive of the scopes that are set.
How to Enable Script Execution (Step-by-Step)
To enable script execution, you need to set the execution policy to a less restrictive value. The steps vary slightly depending on whether you want the change to apply only to your user account or to all users on the machine.
- Open PowerShell as Administrator. Right-click the Start button and select “Windows PowerShell (Admin)” or “Terminal (Admin)”.
- Run the command that matches your needs:
- For the current user only:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser - For all users (requires admin):
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
- For the current user only:
- Confirm the change when prompted by typing
Yand pressing Enter. - Verify the change with
Get-ExecutionPolicy.
If you need to run a script that is downloaded from the internet and you trust it, you can also unblock the file individually with Unblock-File instead of changing the global policy. That is often a safer approach.
Choosing the Right Execution Policy
Selecting a policy depends on your environment and how you use scripts.
- RemoteSigned is the recommended default for most users. It allows you to write and run your own scripts without friction, while still protecting against unsigned downloaded scripts.
- AllSigned is for environments where strict control is needed, such as enterprise servers. Every script, including your own, must be signed.
- Bypass is useful for temporary situations, like running a script from a deployment tool, but it disables all safeguards and should not be left in place.
- Restricted is the default on client Windows and is fine if you never run scripts.
If you are a developer or IT pro who frequently runs scripts from the internet (e.g., from GitHub), RemoteSigned is the most practical balance. For automated builds or CI/CD pipelines, you might use Bypass within a process scope, which does not permanently change the machine.
Common Problems and How to Fix Them
Even after setting the policy, you may encounter errors. Here are typical issues:
- “Running scripts is disabled on this system” – The execution policy is still Restricted. Check with
Get-ExecutionPolicyand set it to RemoteSigned or less restrictive. - “Access to the registry key is denied” – You are not running PowerShell as Administrator. Close and reopen as admin.
- “The term 'Set-ExecutionPolicy' is not recognized” – You are in a different shell (like Command Prompt). Type
powershellfirst or use the full path. - Group Policy overrides your setting – If your organization enforces a policy via Group Policy, you cannot override it locally. Contact your IT admin.
- Script still blocked after setting RemoteSigned – The file was downloaded from the internet and is marked with the Zone.Identifier alternate data stream. Use
Unblock-Fileon the specific file.
Execution Policy vs. Running Scripts Directly
You can often bypass the execution policy without changing it. For example, you can run a script by invoking it with the -File parameter from the command line, or by using the -ExecutionPolicy Bypass switch when starting PowerShell:
powershell -ExecutionPolicy Bypass -File C:\path\to\script.ps1
This is useful for running a one-off script without altering the system. However, be aware that this still runs the script, and you should only do this with scripts you trust.
Safety Considerations
Changing the execution policy reduces a safeguard, so it is important to understand the risks. A script can perform any action your user account can – deleting files, changing settings, or sending data. Only enable script execution if you need it, and prefer the least permissive policy that works.
Always review scripts from the internet before running them. If you use RemoteSigned, you can still run unsigned downloaded scripts by unblocking them, but that is a manual action that forces you to consciously trust the file.
For administrators managing multiple machines, consider using Group Policy to set the execution policy centrally, rather than changing it on each machine individually. This ensures consistency and makes it easier to enforce security standards.
Frequently Asked Questions
How do I permanently enable script execution in PowerShell?
Run Set-ExecutionPolicy RemoteSigned as Administrator. This changes the LocalMachine scope, which persists across reboots. To make it permanent for just your user, use -Scope CurrentUser.
Why can't I run a .ps1 file even after setting the policy?
If the file was downloaded from the internet, it may have a “Mark of the Web” that blocks it. Use Unblock-File -Path .\script.ps1 to remove that mark, then run it again.
Is it safe to use the Bypass execution policy?
It is safe only if you are running a script you fully trust and you understand the risks. Bypass disables all warnings and blocks, so a malicious script can run without any prompts. It is best used temporarily, not as a permanent setting.
What is the difference between RemoteSigned and AllSigned?
RemoteSigned allows all local scripts to run without a signature, but requires downloaded scripts to be signed. AllSigned requires every script to have a valid digital signature, including those you write yourself. AllSigned is more secure but requires you to obtain a code-signing certificate.
Can I set the execution policy for a single script without changing the global policy?
Yes. Use the -ExecutionPolicy parameter when launching PowerShell: powershell -ExecutionPolicy Bypass -File script.ps1. This applies only to that PowerShell session.
Does the execution policy apply to PowerShell Core (pwsh) on Linux or macOS?
Yes, PowerShell Core also has execution policies, but the default is often Unrestricted on non-Windows platforms because the security model is different. You can still set it with the same cmdlets.