|
By default, Microsoft disables the ability to execute PowerShell scripts out of the box. Normally, one would need to manually change this policy to 'Unrestricted' before he or she is able to run scripts.
The PowerShell Syntax for seting the Execution Policy to Unrestricted is: PS > Set-ExecutionPolicy Unrestricted
To set the Policy back to Restricted: PS > Set-ExecutionPolicy Restricted
To query the status of the Execution Policy: PS > Get-ExecutionPolicy
Setting the policy manually can be disconcerning for those who automate their installation scripts and would like to start incorporating PowerShell scripts as part of that framework. So now you have the .Net Framework and the PowerShell install automated, but now manual intervention is required before you can start running your PowerShell scripts. Bum. But wait! There is a way to automatically set the Execution Policy. The Execuction Policy is stored in the registry at this location: | Registry Key | Registry Value |
|---|
HKLM\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell
| ExecutionPolicy
|
| Data | Default |
|---|
| Restricted | Yes
| Unrestricted
| |
Changes to this registry value is immediate. Even if a PowerShell console is currently opened. So by including something like a REG.EXE (from the Windows 2003 Resource Kite) statement in your PowerShell installation script, you can unlock the power of your PowerShell Scripts.
|