Get-xRDS_CollectionsList.ps1
function Get-xRDS_CollectionsList ([Parameter(Mandatory=$true)][string]$ConnectionBroker,[PSCredential]$Credential) { $Collection = @{} $OutCollection = @{} Try { $ActiveManagementServer = (Invoke-WmiMethod -ComputerName $ConnectionBroker -Class "Win32_RDMSEnvironment" -Namespace "root\CIMV2\rdms" -Name "GetActiveServer").ServerName Get-WmiObject -Credential $Credential -ComputerName $ActiveManagementServer -Query "SELECT Alias, Name FROM Win32_RDSHCollection" -Namespace "root\CIMv2\rdms" | %{$Collection.Add($_.alias,$_.name)} Get-WmiObject -Credential $Credential -ComputerName $ActiveManagementServer -Query "SELECT Name, CollectionAlias FROM Win32_RDSHServer" -Namespace "root\CIMv2\rdms" | %{$OutCollection.Add(($_.Name),$Collection[$_.CollectionAlias])} } Catch {Write-host $_.Exception.message -ForegroundColor Red} return $OutCollection } |