If you know how to write simple PowerShell or Batch scripts, you can automate quite a few things on Windows 10. In fact, even if you have to spend a little time writing the perfect script for something, the time saved once it’s good to go will be worth the time you spent writing it. That said, scripts can be dangerous which is when you try to run scripts in PowerShell, you get a rather long error message that essentially tells you “running scripts is disabled on this system”.
This is a security measure in PowerShell to prevent malicious scripts from running and potentially harming the system. Of course, a script that you’ve written yourself isn’t going to be malicious and should be able to run. To fix this problem, you need to change the execution policy in PowerShell. Here’s how.
Fix running scripts is disabled on this system
Open PowerShell with admin rights, and run the following command.
This will show you the execution policy that has been set for your user, and for your machine. It’s likely that both, or at the very least the CurrentUser policy is set to Restricted.
To fix the “running scripts is disabled on this system” error, you need to change the policy for the CurrentUser. To do that, run the following command.
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Confirm that you want to make the change, and you will be able to run the script.
This should allow you to run most scripts however, if you’re still getting the same error, then you probably need to change the execution policy for the machine. You can modify the previous command to do so but you will need admin rights to do this.
Run this command.
Set-ExecutionPolicy RemoteSigned -Scope LocalMachine
Confirm that you want to make the change, and then try running the script.
This should do the trick if you’ve written the script yourself however, if you downloaded it online, and it isn’t signed, then you need to change the execution policy to Unrestricted. To do that, replace “RemoteSigned” in all of the above commands with “Unrestricted”. Be very careful which scripts you run if you’re downloading them. They can be dangerous.
This is a fairly simple command for setting the execution policy on PowerShell. This command can have four different parameters, or states: Restricted, AllSigned, RemoteSigned, and Unrestricted.
The -Scope switch defines what the policy change is applied to. When you enter “CurrentUser”, it is applied to the current user only, and when you enter “LocalMachine”, it’s applied to the entire system