Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I try to execute my PowerShell script I get this error:

File C:\Common\Scripts\hello.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:13
+ .\hello.ps1 <<<<
+ CategoryInfo : NotSpecified: (:) [], PSSecurityException
+ FullyQualifiedErrorId : RuntimeException

share|improve this question

3 Answers 3

up vote 81 down vote accepted

Enable running unsigned scripts by entering:

set-executionpolicy remotesigned

This will allow running unsigned scripts that you write on your local computer and signed scripts from Internet.

See also Running Windows PowerShell Scripts

share|improve this answer
8  
+1 for remotesigned instead of unrestricted. You can run your local scripts without exposing yourself to dangers from everywhere else. –  DarrellNorton Mar 26 '11 at 13:06
4  
Thanks - this post helped me. However I still had further problems because I hadn't run PowerShell "as Administrator" under win8 –  sergeantKK Nov 29 '12 at 13:46

The Default Execution Policy is set to restricted, you can see it by typing:

Get-ExecutionPolicy

You should type the following to make it go to unrestricted mode:

Set-ExecutionPolicy unrestricted

Hope this helps

share|improve this answer
5  
-1. that is WAY too open to just execute. RemoteSigned is better. –  TomTom Jul 17 '12 at 20:38
3  
The requiring signing make sense if you expect the user to copy&paste malicious scripts from the internet. If you assume the user isn't stupid, then "remotesigned" doesn't add any security and makes life difficult. –  Guss Nov 11 '12 at 10:41

On my machine that I use to dev scripts, I will use -unrestricted as above. When deploying my scripts however, to an end user machine, I will just call powershell with the -executionpolicy switch:

powershell.exe -noprofile -executionpolicy bypass -file .\script.ps1
share|improve this answer
1  
You may want to combine this trick with a polyglot trick in a .CMD file. See stackoverflow.com/a/8597794/5314 –  Jay Bazuzi Jan 14 '13 at 20:30
    
Nice! I've been deploying sfx's made by winrar rarlabs.com –  BigHomie Jan 15 '13 at 16:09
    
That trick allowed me to run powershell script from Git Bash (MINGW32 bash) –  Kamil Szot Apr 19 at 21:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.