In today’s Ask the Admin, I’ll show you how to configure Remote Desktop Services (RDS) collections using Windows PowerShell.
In Configure RDS Collections in Windows Server 2012 R2, I showed you how to configure collections using Server Manager. RDS collections are groups of RD Session Host servers with a shared set of RemoteApps, session host or VDI desktops that can be published to users. For information on RDS, see Remote Desktop Services Deployment Options in Windows Server 2012 R2 on the Petri IT Knowledgebase.
To complete the instructions below, log in to the RD Connection Broker using an account that has permission to manage RDS.
Open a PowerShell prompt from the taskbar or Start menu, and then use the New-RDSessionCollection cmdlet to create a new collection. In the example below, I’ve given the collection a name, a description, and specified the RDS Session Host and Connection Broker servers using their fully qualified domain names (FQDNs). In your environment, you will need to replace these values as appropriate.
New-RDSessionCollection –CollectionName PetriDesktops –SessionHost srv1.ad.contoso.com –CollectionDescription ‘Desktop sessions’ –ConnectionBroker srv1.ad.contoso.com
To verify the creation of the new collection, use the Get-RDSessionCollection cmdlet, replacing srv1.ad.contoso.com with the name of your RDS Connection Broker.
Get-RDSessionCollection –ConnectionBroker srv1.ad.contoso.com
To remove a collection from an RDS Connection Broker, use the Remove-RDSessionCollection cmdlet as shown here, again replacing the values for -CollectionName and -ConnectionBroker as needed for your environment. Once you’ve run the command, you’ll need to confirm the operation by typing Y and pressing ENTER.
Remove-RDSessionCollection –CollectionName PetriDesktops –ConnectionBroker srv1.ad.contoso.com
Now let’s create a second collection for a RemoteApp, Wordpad in this example. Because I only have one RDS Session Host in this deployment, it was necessary to delete the previous collection because RDS Session Hosts can only participate in one collection at a time. The New-RDSessionCollection cmdlet below is the same as the one above, apart from the -CollectionName and -CollectionDescription, which are different:
New-RDSessionCollection –CollectionName PetriRemoteApps –SessionHost srv1.ad.contoso.com –CollectionDescription ‘Remote Apps’ –ConnectionBroker srv1.ad.contoso.com
Now we need to add an app to the collection using the New-RDRemoteApp cmdlet:
New-RDRemoteApp -Alias Wordpad -DisplayName WordPad -FilePath ‘C:\Program Files\Windows NT\Accessories\wordpad.exe’ -ShowInWebAccess 1 -CollectionName PetriRemoteApps -ConnectionBroker srv1.ad.contoso.com
To see the list of apps in the collection, use the Get-RDRemoteApp cmdlet, replacing the -ConnectionBroker and -CollectionName parameters values for your environment:
Get-RDRemoteApp -ConnectionBroker srv1.ad.contoso.com -CollectionName PetriRemoteApps
To remove an app from a collection, use the Remove-RDRemoteApp cmdlet, and confirm the operation when prompted.
Remove-RDRemoteApp -Alias Wordpad -CollectionName PetriRemoteApps -ConnectionBroker srv1.ad.contoso.com
In this article, I showed you how to create, enumerate, and remove collections from RDS Connection Brokers, and how to add and remove RemoteApps to collections.