
This is more like how we would do this: #Load Citrix Modules $emailBody = "The following desktops were forcefully restarted due to not registering with the DDCs in a timely manner. #Send an email report of VMs to be restarted due to being in an unregistered state

#Write-Host "Hello, I am unregistered: $unregisteredVM" Sc \\$unregisteredVM start PorticaService Set-Service -Name PorticaService -Status Running $icaservicestate = Get-Service PorticaService -ComputerName $unregisteredVM | select status #If powered-on and unregistered, perform a forceful restartįoreach ($unregisteredVM in $unregisteredVMs) Send-mailmessage -from $fromEmail -to $recipients -subject " XenDesktop Daily Check - $date" -body $emailBody -priority High -smtpServer $server $emailBody = "There were no powered on desktops in an unregistered state." $emailVMs = Get-BrokerDesktop -RegistrationState Unregistered | Select MachineName | ft -wrap -autosize | Out-String $unregisteredVMs = Get-BrokerDesktop -RegistrationState Unregistered | Select MachineName Sorry I'm new to powershell and programming in general.

It seems like the Get-Service command doesn't like the Array Below is the code however it is not running for me. Like to iterate through a loop where I use Get-Service to check the status and if it's stopped then start it and if not just restart the service. I've installed the xendesktop SDK for powershell scripts and need to get a little of "unregistered desktops" and then from that list retrieve the machine name. We use Citrix and we run into issue's where Desktops unregister.
