23

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.

3 Answers 3

14

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)

1
  • 8
    This is what I did, but I felt dirty afterwards. Jun 24, 2009 at 19:18
22

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.

2
2

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."

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .