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.
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 runSet-ExecutionPolicy
and give it one of these as a parameter:Also have a read of Scott Hanselman's words of wisdom on signing Powershell scripts.
The easiest solution is to
but that will run all scripts that are on the local disk (and are not in a Remote zone - like downloaded via IE)
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:
Will run any script on the local machine, that has not come from the internet
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."