Get Remote Desktop Services info

I wanted to have a way to document my Remote Dekstop Services environment (Connection broker, Session Host, Gateway, Remote Applications), thus I created a script that does just that. In case of the script I’m sharing here, this will create exports to CSV for the different items. These are the exports:

  • RDRServersAndRoles.csv – Export of a list of all servers in the farm and their roles (Connection broker, gateway, RD server, web access)
  • RDRemoteSessionHostInfo.csv – Export Remote Session Host information (collection name, sessionhost, connections allowed)
  • RDRemoteAppInfo.csv – Export of all remote apps information and their settings (collection name, displayname, foldername, filepath, icon path, user groups, etc)
  • RDCBRHA.csv – Export of the Connection Broker High Availability settings (client access name, database connection string, database file path)
  • RDGatewayConfiguration.csv – Export gateway configuration (gateway mode, gateway fqdn, logon method, use cached credentials, bypass local)
  • RDSessionCollection.csv – Export the session collection information (collection name, alias, description, server size, resource type, etc)

When running the script you’ll need to enter some parameters:

[Parameter(Mandatory=$true)][string]$ConnectionBrokerName, [Parameter(Mandatory=$false)][string]$ExportFolder = "C:\temp"

Default it’ll export all files to C:\temp, if you want another folder, set the value for the parameter ExportFolder when executing the script. You will however need to enter the name of one of your Connection Brokers with the ConnectionBrokerName parameter. If you omit this value, the script will ask you for it, as it is a mandatory parameter. At first I get the active Connection Broker, as the other commands need to be ran against this CBR. Then I start to gather information.

$ActiveCBR = (Get-RDConnectionBrokerHighAvailability -ConnectionBroker $ConnectionBrokerName).ActiveManagementServer
$ServersAndRoles = Get-RDServer -ConnectionBroker $ActiveCBR | Select-Object Server,@{label="Roles";expression={[string]$_.Roles}}
$GatewayConfiguration = Get-RDDeploymentGatewayConfiguration -ConnectionBroker $ActiveCBR
$SessionCollection = Get-RDSessionCollection -ConnectionBroker $ActiveCBR
$AllRDSServers = Get-RDSessionCollection -ConnectionBroker $ActiveCBR | Select-Object -Property collectionname | ForEach-Object -Process { Get-RDSessionHost -ConnectionBroker $ActiveCBR -CollectionName $_.collectionname | Sort-Object -Property SessionHost}
$CBRHA = Get-RDConnectionBrokerHighAvailability
$Collections = $AllRDSServers.CollectionName | Select-Object -Unique
Foreach($Collection in $Collections)
$RemoteApps += Get-RDRemoteApp -CollectionName $Collection -ConnectionBroker $ActiveCBR | Select-Object CollectionName,Alias,DisplayName,FolderName,FilePath,FileVirtualPath,CommandLineSetting,RequiredCommandLine,IconPath,@{label="UserGroups";expression={[string]$_.UserGroups}},ShowInWebAccess

In the end of the script I will export it all to CSV (and have set the delimiter to “;”, you may have to change this if this is this is not the default delimiter setting for your country.

You can download the entire script here.

2 thoughts on “Get Remote Desktop Services info

  1. Started writing my own RDS collection script, went searching for how to grab a few of the parameters, and stumbled on this all done for me! Many thanks for this, there’s very few pieces of info on how to collect RDS info online. Giving the post some love and affection.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s