Software & OS

How to Enable Running Scripts in PowerShell (Execution Policy)

To enable running scripts in PowerShell, open a normal (non-administrator) PowerShell window and run Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser. The change applies immediately, only to your user account, and lets local scripts run.

Check the result with:

Get-ExecutionPolicy -List

The CurrentUser row should now read RemoteSigned. If a Group Policy row shows something other than Undefined, read the section on Group Policy below, because that setting wins.

Why PowerShell says scripts are disabled

PowerShell's execution policy is a safety feature that controls when PowerShell loads configuration files and runs scripts. If no scope has a policy set, Microsoft documents the effective policy as Restricted on Windows clients and RemoteSigned on Windows Server. Restricted permits individual typed commands but blocks every script file, including module files (.psm1) and your PowerShell profile (.ps1). So a freshly installed Windows 11 machine can run commands but refuses .\script.ps1, and a blocked profile can show an error each time you open a window.

Microsoft's own pages are slightly inconsistent about which policy is the shipped default on a client, so do not rely on this article or any other. Run Get-ExecutionPolicy on your machine and read the answer.

Which policy to pick

You only need to know five of the values. Microsoft's descriptions, shortened:

PolicyEffect on scripts
RestrictedNo script files run. Typed commands still work.
AllSignedEvery script must be signed by a trusted publisher, including ones you write yourself.
RemoteSignedLocal scripts run. Scripts downloaded from the internet must be signed, unless you unblock them with Unblock-File.
UnrestrictedUnsigned scripts run. You are warned before running scripts that are not from the local intranet zone.
BypassNothing is blocked, and there are no warnings or prompts.

For a personal computer where you write or copy your own scripts, RemoteSigned is the usual choice: it enables scripts but keeps one check in place for files that came from a browser or an email program. Bypass is meant, per Microsoft, for setups where PowerShell is built into a larger application that has its own security model. It is a poor everyday setting.

Enable scripts for your user only

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

This is the form Microsoft shows in its examples. The setting is saved in your user-specific powershell.config.json file and stays until you change it. You do not need to restart PowerShell, and you do not need administrator rights. PowerShell may ask you to confirm the change; answer Y. Adding -Force suppresses all confirmation prompts, so use it only in scripts where you have already decided.

Enable scripts for every user on the computer

Leave out -Scope and the cmdlet uses LocalMachine, which affects everyone who uses the computer:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

Start PowerShell with Run as administrator first, or the command fails. In Windows 11, you can do that by right-clicking the Start button and choosing the Terminal (Admin) entry, or by searching for PowerShell and choosing Run as administrator. Prefer CurrentUser unless you really need every account covered, because the narrower scope changes less.

Enable scripts for one session only

The Process scope lasts only as long as the current PowerShell window:

Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process

The value is kept in memory, in the environment variable $Env:PSExecutionPolicyPreference, rather than in a configuration file, and it is deleted when you close the session. Process has the highest precedence of the three local scopes, so it beats whatever is saved for CurrentUser and LocalMachine. This is the cleanest way to run one script you have read, without leaving a permanent change behind.

You can set the same thing when you start a new session. Microsoft documents the -ExecutionPolicy parameter on pwsh.exe, and Windows PowerShell 5.1 (powershell.exe) has the same parameter:

powershell.exe -ExecutionPolicy Bypass -File .\script.ps1

Again, the policy applies only to that session and its child sessions, and it does not override a Group Policy.

Check what is actually in effect

Get-ExecutionPolicy with no parameters shows the effective policy for the current session. Get-ExecutionPolicy -List shows every scope in precedence order. This is Microsoft's sample output (example output, your values will differ):

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser    RemoteSigned
 LocalMachine       AllSigned

Here the effective policy is RemoteSigned, because CurrentUser takes precedence over LocalMachine. Microsoft warns that a command to change the policy can succeed and still not change the effective policy, for exactly this reason: a command that sets LocalMachine can be overridden by a value already set for the current user.

To read a single scope, use Get-ExecutionPolicy -Scope CurrentUser.

When Group Policy blocks the change

The MachinePolicy and UserPolicy rows come from Group Policy, the Turn on Script Execution setting under Administrative Templates\Windows Components\Windows PowerShell. It overrides the policy you set in PowerShell in every scope. If you disable that setting, scripts do not run, which is equivalent to Restricted. If you enable it, the administrator picks one of three values: allow all scripts (Unrestricted), allow local scripts and remote signed scripts (RemoteSigned), or allow only signed scripts (AllSigned).

When you try to override it, PowerShell saves your preference but reports the conflict. Microsoft's example of the message (example output):

Set-ExecutionPolicy : PowerShell updated your local preference successfully, but the setting is
overridden by the Group Policy applied to your system. Due to the override, your shell will retain
its current effective execution policy of "AllSigned". Contact your Group Policy administrator for
more information.

On a work or school computer, this means the policy is deliberate. Ask the administrator rather than looking for a way around it.

A downloaded script is still blocked under RemoteSigned

Browsers and email programs add an alternate data stream to downloaded files that marks them as coming from the internet. Under RemoteSigned, PowerShell will not run an unsigned script that carries that mark, and reports that the file is not digitally signed. Read the script first, then clear the mark on that one file:

Unblock-File -Path .\script.ps1

That runs the script without changing the execution policy at all. Files fetched with curl.exe, Invoke-RestMethod or Invoke-WebRequest may not get the mark, according to Microsoft. For the full walkthrough of running a script once it is allowed, including paths with spaces and right-click behavior, see How to run a PS1 file in Windows PowerShell. For commands to put in your first script, see PowerShell basic commands.

Windows PowerShell and PowerShell 7 are separate

Microsoft notes that Windows PowerShell 5.1 and PowerShell 6.0 and higher store the policy in different locations and are managed separately. A change made in powershell.exe does not affect pwsh.exe. If scripts work in one window and fail in another, run the same Set-ExecutionPolicy command in the window that fails.

On macOS and Linux the question does not arise. The default there is Unrestricted and cannot be changed, and the behavior really matches Bypass.

Turn the restriction back on

To remove a policy you set, set it to Undefined for that scope:

Set-ExecutionPolicy -ExecutionPolicy Undefined -Scope CurrentUser

If no scope has a policy after that, the effective policy returns to Restricted on a Windows client. Use -Scope LocalMachine from an administrator window to remove a machine-wide setting.

Is changing the execution policy a security risk?

Microsoft's documentation says the execution policy is not a security boundary but a form of defense in depth. Anyone who cannot run a script can type or paste its contents at the prompt instead. The policy exists to help people follow basic rules and to stop accidental violations. That cuts both ways: enabling scripts does not make your computer much less safe by itself, and leaving them disabled does not protect you from something you paste in deliberately. What keeps you safe is reading a script before you run it, and getting scripts only from sources you trust.

Frequently asked questions

Is it safe to set the execution policy to RemoteSigned?
RemoteSigned is the policy Microsoft documents as the default for Windows Server, and it still blocks unsigned scripts that carry the downloaded-from-the-internet mark. It does not check scripts you wrote or copied locally, so it protects against accidents, not against a script you choose to run. Microsoft states that the execution policy is not a security boundary.
Do I need administrator rights to enable scripts?
Not for the CurrentUser or Process scopes. Microsoft says you need a Run as administrator session only to change the LocalMachine scope, which is also the default scope when you leave -Scope out.
Why did Set-ExecutionPolicy succeed but scripts still do not run?
A higher-precedence setting is overriding yours. Process outranks CurrentUser, and CurrentUser outranks LocalMachine. A Group Policy (the MachinePolicy and UserPolicy rows) overrides all of them. Run Get-ExecutionPolicy -List to see which row wins.
How do I undo the change?
Set the policy to Undefined for the scope you changed, for example Set-ExecutionPolicy -ExecutionPolicy Undefined -Scope CurrentUser. If every scope is Undefined, the effective policy is Restricted on Windows clients.

Sources