During the deployment of the startup tasks used to create Event Logs in a previous post I noticed a number of errors with the roles deploying into a busy loop and never successfully deploying when trying to execute these tasks.

This turned out to be a problem with the version of PowerShell running in the Windows Azure operating system that you are trying to boot and can be solved by specifically setting the osFamily within the Service Configuration file to family 2. This then ensures that the image used is made from Windows Server 2008 R2 and has full support for PowerShell version 2 allowing unrestricted execution without changing registry settings (as would be needed if using osFamily = “1”).

The below snippet has been used to force the OS to the correct version needed for our scripts: