Powershell error : “.ps1 cannot be loaded because the execution of scripts is disabled on this system”

When You are trying to run a PS1 script in Power shell you are getting the following error:

“File C:\scripts\.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:19

+ c:\scripts\.ps1 <<<<”

 

 

 

 

 

 

 

The security settings built into Windows PowerShell include something called the “execution policy;” the execution policy determines how (or if) PowerShell runs scripts. By default, PowerShell’s execution policy is set to Restricted; that means that scripts – including those you write yourself – won’t run.

You can see it by runnig to command: Get- ExecutionPolicy

As you can see , Its restricted

 

 

 

 

 

For enabling it just run :

Set-ExecutionPolicy -ExecutionPolicy Unrestricted

Now you can run your PS1 script

*Note: the unrestricted option will allow  All scripts from all sources can be run without signing

A safer option will be tp run

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned


This entry was posted in PowerShell, Windows and tagged , . Bookmark the permalink.

Leave a Reply