Powershell DSC xRDSessionDeployment Continuously Reboots

==Updated 24th Feb with more information==

When recently deploying a Remote Desktop environment into Azure with ARM and the DSC extension I encountered an issue when I got to calling the xRDSessionDeployment resource to create the new deployment. The deployment would be created OK, but this would then be followed by the machine rebooting 5-10 times before DSC finally generated an error and would not move on to the next task. My DSC extension logs where full of this message:

A reboot is required to progress further.  
Please reboot the system. Configuration will not be continued after the reboot. To continue configuration, use  
Start-DscConfiguration -UseExisting after reboot.

After some help from Microsoft we got to the bottom of the issues, which is down to a fault in the xRDSessionDeployment resource. As part of the test-targetresource part of the configuration the following check is used to confirm that there is an active session deployment

 (Get-TargetResource @PSBoundParameters).SessionHost -ieq $SessionHost  

The problem is, (Get-TargetResource @PSBoundParameters).SessionHost returns a value in upper case, where as $SessionHost is in lowercase. Due to the ieq comparison case is considered. To resolve this you can either use -eq rather than -ieq

 (Get-TargetResource @PSBoundParameters).SessionHost -eq $SessionHost  

Or alternatively change $SessionHost to upper case:

 (Get-TargetResource @PSBoundParameters).SessionHost -ieq $SessionHost.ToUpper()  


It turns out that after some testing this was not the cause of the issue and it re-occurred. Further investigation leads me to believe that the cause of the issue is that the Remote Dekstop Management Service is on a delayed start, so when the machine reboots after deploying RDS, and DSC runs to continue the configuration, that this service has not yet started and so it fails the test.
To resolve this we updated the get-targetresource section to add this line at the start:

 Start-Service -Name RDMS -ErrorAction SilentlyContinue  

So this funciton now reads:

function Get-TargetResource {  
    [CmdletBinding()] [OutputType([System.Collections.Hashtable])] param  
        [parameter(Mandatory)] [string] $SessionHost,  
        [parameter(Mandatory)] [string] $ConnectionBroker,  
        [parameter(Mandatory)] [string] $WebAccessServer  
    Start-Service -Name RDMS -ErrorAction SilentlyContinue

    Write-Verbose Getting list of RD Server roles.  
    $Deployed = Get-RDServer -ErrorAction SilentlyContinue  
        SessionHost      = $Deployed | ? Roles -contains RDS-RD-SERVER | % Server;  
        ConnectionBroker = $Deployed | ? Roles -contains RDS-CONNECTION-BROKER | % Server;  
        WebAccessServer  = $Deployed | ? Roles -contains RDS-WEB-ACCESS | % Server;  

This appears to have solved the issue.