Follow sqlserver-dba.com

Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions

SQLServer-DBA.com Links

Dba_db2_button

dba-ninja.com

SQL Server DBA Jobs

Powershell – setting the Execution Policy

12 February,2011 by Tom Collins

When you attempt to execute a Powershell script you may see something like the following error message:

 File C:\general.ps1 cannot be loaded because the execution of scripts is di

sabled on this system. Please see "get-help about_signing" for more details.

At line:1 char:14

+ ./general.ps1 <<<<  -inputfile "create_sql2008.sql"

    + CategoryInfo          : NotSpecified: (:) [], PSSecurityException

    + FullyQualifiedErrorId : RuntimeException

 This means the Execution Policy is not set with appropriate permissions.

 The Execution Policy defines the level of restriction on Powershell script execution.

The 4 levels possible are:

All Signed   - (Script must be signed by a trusted publisher)

Remote Signed  - (Scripts downloaded scripts must be signed by a trusted publisher)

Unrestricted – (All scripts can be run)

Restricted – (Can’t run any any scripts.Interactive mode)

 To check your current level use Get-ExecutionPolicy :

 PS> Get-ExecutionPolicy
All signed

PS>

 

 

To change your policy use Set-ExecutionPolicy such as. Be careful which Policy you choose :

 Set-ExecutionPolicy  RemoteSigned

Source:Jack Vamvas (http://www.sqlserver-dba.com)
Author: Tom Collins (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on Powershell – setting the Execution Policy


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer