PowerShell: get list of RDS Collections

2.5k Views Asked by At

Very new to PowerShell here... I'm trying to use PowerShell to get a complete list of Collection Names from our RDS environment. Preferably, these names would be stored in an array so that I can cycle through the list one collection name at a time.

I found this command:

 Get-RDVirtualDesktopCollection -ConnectionBroker $ActiveCB  

It works, but it displays a pretty table that includes the CollectionName, Type, Size, and PercentInUse.

I don't want a pretty table, I just need the list of Collection Names. I know the above command returns an object of type Microsoft.RemoteDesktopServices.Management.RDVirtualDesktopCollection, but I'm not sure what to do with that.

How can I produce the list of collection names that I need?

Thank you in advance!

1

There are 1 best solutions below

1
On

Of course, I figure out as soon as I post. Here's the answer:

Take the returned object and use the property CollectionName. Like this:

$foo = Get-RDVirtualDesktopCollection -ConnectionBroker $ActiveCB  
echo $foo[0].CollectionName

Much simpler than I made it out originally...