12 February,2011 by Jack Vamvas
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 :
To change your policy use Set-ExecutionPolicy such as. Be careful which Policy you choose :
Set-ExecutionPolicy RemoteSignedSource:Jack Vamvas (http://www.sqlserver-dba.com)