XenDesktop XenApp 7.x - vmware / ad / delivery group notes and descriptions sync

· 2 min read

Several times i had the need to synchronise Virtual Machine notes (vmware) with Active Directory Computer description. As in big environment, different team are managing each of these components, the need to be able to link an Active Directory computer account to a vm with XenApp / XenDesktop delivery group has often been seen as useful.

Delivery group name : Desktop123


Virtual Machine note (vmware) : Desktop123


Active Directory account Description : Desktop123


The idea is to simply synchronise the information through the platforms so everyone knows quickly what machine does what. In this particular example that was about XenApp Servers and XenDesktop VDI.

You will need a machine where :

  • XenDesktop 7.x SDK (Powershell is installed)
  • vmware PowerCli installed
  • RSAT role deployed as well
Add-PSSnapin Citrix*
Add-PSSnapin vmware*
Import-module ActiveDirectory
Connect-VIServer $vcenter
$XDDC = "yourXDControllerFQDN:80"
$vcenter = "yourvCenterFQDN"
#Get-BrokerMachine  -AdminAddress $XDDC -Filter "((SessionSupport -eq `"SingleSession`" -or SessionSupport -eq `"MultiSession`"))" -Skip 0 | Select-Object HostedMachineName,DesktopGroupName | Export-Csv $file1 -Delimiter ";" -Encoding UTF8 –NoTypeInformation
foreach ($list in (Get-BrokerMachine  -AdminAddress $XDDC -Filter "((SessionSupport -eq `"SingleSession`" -or SessionSupport -eq `"MultiSession`"))" -Skip 0 | Select-Object HostedMachineName,DesktopGroupName)) {
    if ($list.HostedMachineName -eq $null) {
    Write-Host "No Machine" -ForegroundColor Red
    Else { Write-Host $list.HostedMachineName -ForegroundColor Green 
Set-VM $list.HostedMachineName -Notes $list.DesktopGroupName -Confirm:$false
Set-ADComputer $list.HostedMachineName -Description $list.DesktopGroupName -Verbose
Disconnect-VIServer $vcenter -Confirm:$false

Thank to Rodolphe Herpeux who simplified the first version of this script I wrote.