There are times that you created some Hosted Shared Desktops. You published them and gave them out. You want to make sure you don’t duplicate your work and create another one when you may have one that is already available for a user group. How about a script to see what you got, what you named it, what Delivery Group is hosting it, what users are assigned to it, and what servers are assigned to it? I’ve got just the script for you!
# Script to get all Hosted Shared Desktops and user assignments using ISE 5.1 and Citrix Studio SDK installed locally.
asnp Citrix*
$date = Get-Date -Format MMddyyyy
$adminAddress = "ddc.fqdn:80"
$getHSD = Get-BrokerEntitlementPolicyRule -AdminAddress $adminAddress -MaxRecordCount 10000
$report = @()
foreach($hsd in $getHSD){
$line = "" | Select-Object PublishedName, IncludedUsers, DeliveryGroup, ServerNames
$desktopGroup = Get-BrokerDesktopGroup -AdminAddress $adminAddress -uid $hsd.DesktopGroupUid
$machineNames = Get-BrokerMachine -AdminAddress $adminAddress -DesktopGroupName $desktopGroup.Name
$line.PublishedName = $hsd.PublishedName
if($hsd.IncludedUsers.Name -ne $null){
$line.IncludedUsers = ($hsd.IncludedUsers.Name -join ';').ToString()
}
elseif($hsd.IncludedUsers.Name -eq $null){
$line.IncludedUsers = "None Assigned"
}
if($desktopGroup.Name -ne $null){
$line.DeliveryGroup = $desktopGroup.Name -join ';'
}
elseif($desktopGroup.Name -eq $null){
$line.DeliveryGroup = "None Assigned"
}
if($machineNames.HostedMachineName -ne $null){
$line.ServerNames = $machineNames.HostedMachineName -join ';'
}
elseif($machineNames.HostedMachineName -eq $null){
$line.ServerNames = "None Assigned"
}
$report += $line
}
$report | Export-CSV c:\scripts\logs\$date-hostedshareddesktops.csv -Append -NoTypeInformation