PowerShell: Execution of Scripts is Disabled on This System

I am pretty new to the PowerShell arena, so I was a little surprised with this error when I tried testing a script:

File C:\script.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see “get-
help about_signing” for more details.
At line:1 char:19

Of course once I researched it, I quickly found that it is to protect the system from running malicious scripts. This technet post from The Scripting Guys really helped (http://technet.microsoft.com/en-us/library/ee176949.aspx)

CAUSE

The PowerShell Execution Policy is set to Restricted by default prevent the use of scripts.

SOLUTION

From the PowerShell prompt
1) Type:

Get-ExecutionPolicy

Restricted should be returned.

2) Type:

Set-ExecutionPolicy RemoteSigned

You should now be able to run your script. This setting will remain even if you exit the PowerShell Session.

NOTES

Restricted – No scripts can run.

Unrestricted – All scripts can run.

RemoteSigned – Run self-created scripts, but require scripts obtained from other sources to be signed by a trusted publisher.

AllSigned – Require ALL scripts to be signed by a trusted publisher.

Advertisements
This entry was posted in PowerShell, Windows 7 and tagged , , . Bookmark the permalink.

2 Responses to PowerShell: Execution of Scripts is Disabled on This System

  1. Pingback: PowerShell: Reporting NTFS Permissions of Windows File Shares « My Windows System Administrator

  2. I’m not that much of a online reader to be
    honest but your blogs really nice, keep it up! I’ll
    go ahead and bookmark your website to come back later on.
    Cheers

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s