Lets talk about the execution policy and how it almost hurt us.
Yes sir, the Execution Policy for PowerShell never knew this would ever come.
Here is a way how Microsoft tells us to change the execution policy, run the below commands.
The above commands change the policy just for the PowerShell session they are made on but not for all the following PowerShell sessions.
However the group policy always takes precedence over the Local Policy.
We were doing a SQL server migration for 2005 to 2012 which included migrating the Database AppFabric Caching cluster servers are using.
As many of you know AppFabric heavily relies on PowerShell to make its configuration changes.
I will come up with another blog on how to do that manually but lets focus on how we were bit by this policy setting.
Figures that Executable (AppFabric Config Wizard) was trying to use an ExecutionPolicy other than what was set in the Group Policy Object.
The GPO was set to Unrestricted and the Executable was trying to use AllSigned.
This resulted in the following exception every time we were trying to register the AppFabric hosts to the new Database instance.
The same when result when we try to change the execution policy for the PowerShell sessions as well.
Enough said and let me come to the solution.
There are two ways to fix this.
1. Temporary Fix to get you through the evening.
Delete the registry key named ExecutionPolicy that is being pushed by the Group Policy object located at
Hive : HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\PowerShell
2. Permanent Fix to make sure this never happens again.
Work with your Domain Admins or who ever controls the Group Policies at the Active Directory level and have them set the execution policy to undefined.
The Group Policy configuration in Windows Server 2008 (and Windows Server 2003) allows a GPO to be set to configure the PowerShell operation level centrally. Within Group Policy, navigate to
Computer Configuration > Administrative Templates > Windows Components > Windows > PowerShell and configure the Script Execution setting