This is an egoistic post, but I need to remember this piece of information, so I’ll put it in a place I’m sure I’ll find it again. I might do that a little more often if my Google searches take too long (or my memory fails more often).

The problem: How do I run a .ps1 file (Powershell script) from within Powershell?

Attempt 1:

PS C:foo> .Install.ps1
File C:fooInstall.ps1 cannot be loaded. The file C:fooInstall.ps1 is
not digitally signed. The script will not execute on the system. Please
see "get-help about_signing" for more details..
At line:1 char:13
+ .Install.ps1 <<<<

Ok, strange but secure. How do you switch it off?

Read here for the details or continue for the summary:

The command “Get-ExecutionPolicy” will return the policy you are currently running with.

There are three options for the execution policy that you can set:

  • AllSigned (default): all scripts need to be signed.
  • RemoteSigned: Only scripts downloaded from the internet must be signed.
  • Unrestricted: Any scripts will run without being signed.

I changed the policy using “Set-ExecutionPolicy RemoteSigned” and voila…

Advertisements