Tuesday, 17 May 2011

Setting the PowerShell execution policy - the trap

I was recently pulling my hair out trying to run a powerShell script in VisualStudio. I kept getting the error: "File SomeScript.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details."

So I ran the script:
powershell set-executionpolicy remotesigned

Tried a gain, and still it fails! Only until I spoke to my developer collegue Damian Powell did he say you actually have to run that command for both x86 and x64 powershells.

So I ran:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell set-executionpolicy remotesigned
C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell set-executionpolicy remotesigned

Hey presto! All works. Thanks Damian!