Monday, October 03, 2011

Running Powershell Script without the Headache of Signing Scripts

Powershell can have a direct effect on Windows and therefore has some built in security.

This security can be a real PAIN IN THE BUTT when it comes to just wanting your
script to run.

You will see a warning :
File C:\scripts\test.ps1 cannot be loaded because the execution of
scripts is disabled on this system. Please see "gethelp about_signing" for more details.


Now, to create your own signature certificate is a headache all unto itself.

This is how you can get around it:

At a Powershell command line type: Get-ExecutionPolicy

Possible return values are: Restricted, Unrestricted, RemoteSigned, AllSigned, Bypass

To run Powershell script without a signature requirement, the Execution Policy must be
set to Bypass.

You could type Set-ExecutionPolicy bypass, but chances are it will squawk at that and
tell you that changes could not be made to the registry.

1. Login to the machine where your script will run. (If on a server, you may want to
use a domain account)

2. Open Powershell (Start/Accessories/WindowsPowershell)

3. Type at the command line:
Set-ExecutionPolicy –scope CurrentUser –executionpolicy bypass –force

This command allows you to force the Execution Policy to Bypass for any code the User wants to run.

No comments: