Saturday, March 2, 2013

PowerShell: Running Unsigned Scripts

Although you may fire up PowerShell and enter commands at will, if you attempt to run a script file, initially you may receive an error:

File cannot be loaded because the execution of scripts is disabled on this system.

By default things are locked down. Scripts must be signed in order to be executed. This is for trust and security purposes. However, for development and staging/testing environments, you probably just want it to run.

Simple fix!

All you need to do is modify the execution policy by issuing one of the following cmdlets:

Set-ExecutionPolicy remotesigned
   -- or --
Set-ExecutionPolicy unrestricted

The remote signed protects against downloaded scripts and insures that they must be signed. Unrestricted allows any script to be run so that's what I do in development and staging/testing:


The remote signed is probably good for production depending on your IT policies.
 

No comments:

Post a Comment

Matched Content