If you’re working with PowerShell scripts on your Windows computer, you’ll likely need to adjust the execution policy at some point. The execution policy determines the conditions under which PowerShell loads configuration files and runs scripts. In this tutorial, I will explain how to set the execution policy in PowerShell with the complete script.
To set the execution policy in PowerShell to RemoteSigned for the current user, open PowerShell as an administrator and run the command: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser. This ensures that a trusted publisher must sign any scripts you download before they can be executed, enhancing security while allowing script execution.
What is Execution Policy in PowerShell?
Execution policies in PowerShell are a safety feature that controls the conditions under which PowerShell loads configuration files and runs scripts. It helps protect your system from running malicious scripts. There are several types of execution policies you can set:
- Restricted: No scripts can be run. PowerShell can only be used in interactive mode.
- AllSigned: Only scripts signed by a trusted publisher can be run.
- RemoteSigned: Downloaded scripts must be signed by a trusted publisher before they can be run.
- Unrestricted: All scripts can be run. Downloaded scripts will prompt for permission before execution.
- Bypass: Nothing is blocked, and there are no warnings or prompts.
- Undefined: Removes the currently assigned execution policy from the current scope.
How to Set Execution Policy in PowerShell
To change the PowerShell execution policy, you use the Set-ExecutionPolicy cmdlet. Here’s the basic syntax:
Set-ExecutionPolicy -ExecutionPolicy <PolicyName> [-Scope <Scope>] [-Force] [-WhatIf] [-Confirm]Parameters:
- -ExecutionPolicy: Specifies the new execution policy.
- -Scope: Defines the scope of the execution policy. Scopes include
Process,CurrentUser,LocalMachine. - -Force: Suppresses all prompts.
- -WhatIf: Shows what would happen if the cmdlet runs.
- -Confirm: Prompts for confirmation before running the cmdlet.
Now, let me show you how to use these parameters with examples.
Example 1: Setting Execution Policy to RemoteSigned
Let’s say you want to set the execution policy to RemoteSigned for the current user. Here’s how you can do it:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserThis command ensures that a trusted publisher must sign any scripts you download before they can be executed.
Check out How to Add Credentials in PowerShell Script?
Example 2: Setting Execution Policy to Unrestricted
If you want to allow all scripts to run without any restrictions, you can set the policy to Unrestricted:
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope LocalMachineThis command sets the execution policy for all users on the computer.
Example 3: Bypassing Execution Policy for a Single Session
Sometimes, you might want to bypass the execution policy just for a single session. Here’s how you can do it:
powershell.exe -ExecutionPolicy BypassThis command starts a new PowerShell session with the execution policy set to Bypass.

Check out PowerShell Random Password Generator
Execution Policy in PowerShell – Use Cases
Now, let me show you a few use cases where we need the execution policy in PowerShell.
Running Scripts on a New Machine
When setting up a new machine, you might need to run initialization scripts. Setting the execution policy to RemoteSigned can help ensure that you can run your scripts without compromising security.
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachineAutomating Tasks
For automation tasks, especially in a development environment, you might want to set the execution policy to Unrestricted to avoid interruptions.
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser -ForceConclusion
In this tutorial, I explained how to set the execution policy in PowerShell. I also explained the different parameters available and how to use them.
You may also like the following tutorials:
- Remove Environment Variables in PowerShell
- Set and Get Environment Variables in PowerShell
- How to Get Computer Name in PowerShell?
- How to Prompt for Input in PowerShell?
Bijay Kumar is an esteemed author and the mind behind PowerShellFAQs.com, where he shares his extensive knowledge and expertise in PowerShell, with a particular focus on SharePoint projects. Recognized for his contributions to the tech community, Bijay has been honored with the prestigious Microsoft MVP award. With over 15 years of experience in the software industry, he has a rich professional background, having worked with industry giants such as HP and TCS. His insights and guidance have made him a respected figure in the world of software development and administration. Read more.