Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I tried creating an ultimate setup for my powershell environment.

I created "Microsoft.PowerShell_profiles.ps1" with a bunch of statements to setup my default profile.

When I start a PowerShell session though, I get:

File C:\Documents and Settings\xxx\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 cannot be loaded. The file C:\Documents and Settings\xxx\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 is not digitally signed. The script will not execute on the system.

share|improve this question

3 Answers 3

up vote 2 down vote accepted

The easiest solution is to

Set-ExecutionPolicy RemoteSigned

but that will run all scripts that are on the local disk (and are not in a Remote zone - like downloaded via IE)

share|improve this answer
3  
This is what I did, but I felt dirty afterwards. –  Brett Veenstra Jun 24 '09 at 19:18

By default Powershell restricts you from running "unsafe" scripts. Run the get-executionpolicy command to see what your system's level is at. To lower the restriction you can run Set-ExecutionPolicy and give it one of these as a parameter:

  • Restricted – No scripts can be run. Windows PowerShell can be used only in interactive mode.
  • AllSigned – Only scripts signed by a trusted publisher can be run.
  • RemoteSigned – Downloaded scripts must be signed by a trusted publisher before they can be run.
  • Unrestricted – No restrictions; all Windows PowerShell scripts can be run.

Also have a read of Scott Hanselman's words of wisdom on signing Powershell scripts.

share|improve this answer
    
Great article there –  Brett Veenstra Jun 24 '09 at 19:17
1  
+1 much better answer than the accepted one –  Adriano Varoli Piazza Jul 30 '09 at 15:02

You have 3 options here, you can either get your script signed by a trusted provider, or at least a provider you trust, or you can use the Set-ExecutionPolicy to set powershell to allow external scripts, either:

 Set-ExecutionPolicy RemoteSigned

Will run any script on the local machine, that has not come from the internet

Set-ExecutionPolicy  Unrestricted

Will allow any script to run, although if you downloaded it from the internet it will ask you to confirm you want to run it.

Finally, you can set the particular script to run by right-clicking the file, and click "Properties." At the bottom of the dialogue box click "Unblock."

share|improve this answer

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.