Apr 5, 2011

PowerShell Error: the execution of scripts is disabled on this system

When you run powershell scripts (.pl1), in Windows PowerShell console you may received following error.
 
 
File C:\Projects\Microsoft.Practices.ESB\Source\Samples\Management 
Portal\Install\Scripts\Management_Install.ps1 cannot
be loaded because the
execution of scripts is disabled on this system. Please see "get-help
about_signing"
for more de
tails.
At line:1 char:25
+
.\Management_Install.ps1 <;;;<<< 1
+
CategoryInfo :
NotSpecified: (:) [], PSSecurityException
+
FullyQualifiedErrorId : RuntimeException

Error_powershell 

To fix this, run following command, in the console



set-executionpolicy unrestricted

On 64bit version of Windows 2008R2, also make sure to set this command for 64bit  PowertShell, which can be found in C:\Windows\SysWOW64\WindowsPowerShell\v1.0 


After you done, it is recommended to revert the setting by using



set-executionpolicy restricted
 
        OR
 
set-executionpolicy default