Citrix XenApp: Migrating Delivery Groups, the PowerShell Way

This code will do the heavy lifting, moving all published apps from one Delivery Group to another.

Hopefully someone finds it handy.

In case you’re wondering… yes, it is possible to select just one AdminFolder, and migrate it’s apps. That’s another line of code I haven’t added to this, but it’s out there on the Inter-Webs if you can find it.

Otherwise, if you can find my contact info, I’ll see if I can help you out.

asnp Citrix*

$srcDG = Get-BrokerDesktopGroup -MaxRecordCount 10000 | Select-Object -Property Name,UUID | sort Name | Out-GridView -Title "Select Source Delivery Group Name" -OutputMode Single
$dstDG = Get-BrokerDesktopGroup -MaxRecordCount 10000 | Select-Object -Property Name,UUID | sort Name | Out-GridView -Title "Select Destination Delivery Group Name" -OutputMode Single
$applist = Get-Brokerapplication -MaxRecordCount 10000 | Where-Object {$_.AssociatedDesktopGroupUUIDs -contains $srcDG.UUID.ToString()}

Write-Host "Migrating all applications from [ " -NoNewLine; Write-Host $srcDG.Name -ForegroundColor Red -NoNewLine; Write-Host " ] to [ " -NoNewLine; Write-Host $dstDG.Name -ForegroundColor Green -NoNewLine; Write-Host " ] Delivery Group."

foreach ($app in $applist.Name) {
	Write-host "Migrating $app..." -NoNewline
	Get-BrokerApplication -Name $app | Add-BrokerApplication -DesktopGroup $dstDG.Name
	Get-BrokerApplication -Name $app | Remove-BrokerApplication -DesktopGroup $srcDG.Name
	Write-host "done." -ForegroundColor Green
}