Get ExecutionPolicy

After my laptop crashed last week I moved to Windows 7 OS and since it was a clean install (actually image) I  had to  install a lot of software. One bit of software I did not have to install was PowerShell. That is because it is part of the default install. Yeah!

One of the things I forgot about when first starting to work PowerShell and running scripts is the ExecutionPolicy. When trying to run a script to start SQL Server I ran into this little error.

startService.ps1 cannot be loaded because the execution of scripts is disabled on this system.
Please see “get-help about_signing” for more details.

I forgot about the default execution policy being set to restricted. This is a security feature built into Powershell. You can check your own execution policy by running this command.

# get the execution policy

#This is what PS returned:

PS C:\Users\sqlaj>

How do we fix this you ask? That is the easy part just run this command in PowerShell.

Set-ExecutionPolicy Unrestricted   # (other options are RemoteSigned and AllSigned)

Note, this will allow you to run all scripts even unsigned ones so this does pose a potential security issue to your PC or server if you set this level. To get more detailed information on what “signed” and “unsigned” scripts means type the following command.

Get-Help About_Signing

All the information and code commands I described here can be found here on MS Tech Net



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s