Windows Powershell giving “execution of scripts is disabled” error
I was getting an error when I went to run a PowerShell script. This was the error:
PS C:\> .\kerrys-script.ps1
File C:\kerrys-script.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get -help about_signing" for more details.
At line:1 char:20
+ .\kerrys-script.ps1 <<<<
+ CategoryInfo : NotSpecified: (:) , PSSecurityException
+ FullyQualifiedErrorId : RuntimeException
In order to fix this, I had to run this command:
PS C:\> Set-ExecutionPolicy RemoteSigned
You will see this:
Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose you to the security risks described in the about_Execution_Policies help topic. Do you want to change the execution policy?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"):
Just hit enter and the error will go away and your scripts will work.