blog.powershell.no

On Windows PowerShell and other admin-related topics

Dynamic Remote Desktop Connection Manager connection list

Microsoft recently released a free tool for managing multiple remote desktop connections called “Remote Desktop Connection Manager”.

A sample screenshot:

image

There are several nice features, such as “Connect group” which lets you connect to all servers in a group at once:

image

On the “Group Properties” you may set common settings for all connections in the group, like logon credentials:

image

Further, there are group properties for RDS Gateway (formerly TS Gateway), display settings, local resources and so on.

There are several applications for remote desktop connections on the market, and some of them got these settings as a per server setting. It`s nice to be able to group servers and configure common settings.

Dynamically creating the connection list

When you work in larger environments with hundreds, maybe thousands of servers, setting up each connection manually isn`t an option.

Since Remote Desktop Connection Manager stores the config-files in xml-files, it`s rather easy to create dynamic config-files for a domain using Windows PowerShell. I`ve created a script to accomplish this, called New-RDCManFile.ps1, available from here. It uses Microsoft`s PowerShell-module for Active Directory, which is available in Windows Server 2008 R2 and RSAT for Windows 7.

The script does the following:
Creates a template xml-file
Inserts the logged on user`s domain name in the file properties
Inserts the logged on user`s domain name in the group properties
Inserts the logged on user`s username in the logoncredentials section
Inserts the logged on user`s domain name in the logoncredentials section
Retrieves all computer objects from Active Directory with the word “server” in the operatingsystem property
Adds each computer object as a server object
Saves the XML-file to %userprofile%\domain-name.rdg

When done you can open the rdg-file in Remote Desktop Connection Manager. I would recommend you to insert your password in the Group Properties to avoid being asked for credentials for each connection.

Feel free to customize the script to your needs, in example by editing the XML-template to edit the Group Properties. Another customization might be creating a group for each server OU for enhanced overview in larger environments.

If you would rather use Quest`s PowerShell Commands for Active Directory (which works on downlevel operatingsystems like Windows XP and Windows Server 2003), or any other way to retrieve the server names, you may customize this on line 110.

You might also want to schedule the script to run on a regular basis, saving the file to a central location. This way the IT personnel will always have access to the latest version with the most recent servers added.

If you got any further ideas or comments, please let me know in the comments section below.

Advertisements

June 2, 2010 - Posted by | Active Directory management, Remote Desktop Services, Remote Management, RSAT, Scripting, Windows 7, Windows PowerShell, Windows Server 2008 R2

19 Comments »

  1. Hi Andreas,

    Nice article! But…

    I was getting this error message from your script when using the Quest AD cmdlet’s:

    Cannot set “displayName” because only strings can be used as values to set XmlNode properties.
    At C:\users\ibss077\documents\powershell\Various Scripts\New-RDCManFile.ps1:110 char:9
    + $server. <<<< DisplayName = $($_.Name)
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

    Cannot set "name" because only strings can be used as values to set XmlNode properties.
    At C:\users\ibss077\documents\powershell\Various Scripts\New-RDCManFile.ps1:111 char:9
    + $server. <<<< Name = $($_.DNSHostName)
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

    I've solved it by changing this portion of the script:

    Get-QADComputer -LDAPFilter "(operatingsystem=*server*)" | select name,dnshostname |
    ForEach-Object {
    $server = $server.clone()
    $server.DisplayName = $_.Name
    $server.Name = $_.DNSHostName

    to:

    Get-QADComputer -LDAPFilter "(operatingsystem=*server*)" | select name,dnshostname |
    ForEach-Object {
    $server = $server.clone()
    [string]$server.DisplayName = $_.Name
    [string]$server.Name = $_.DNSHostName

    Hopefully this will help others also.

    Regards, Richard

    Comment by Richard | June 3, 2010 | Reply

  2. Excellent script. I also got the error above (using the AD module). My fix was similar.
    $server.Name = “{0}” -f $_.DNSHostName

    Comment by JBandy | June 7, 2010 | Reply

  3. […] structure you can build yourself. A quick web search turns up a post by Jan Egil Ring titled Dynamic Remote Desktop Connection Manager connection list. The approach Jan takes builds an RDCMan file from the computers in Active Directory using […]

    Pingback by Building A Remote Desktop Manager Connection List | Sev17 | June 15, 2010 | Reply

  4. […] to cover this here, but you should take a look at this post and I highly recommend this article Dynamic Remote Desktop Connection Manager connection list. This is a super cool PowerShell script that makes sure your connection list is always up to […]

    Pingback by What's your Favorite Remote Desktop Manager ? | June 27, 2010 | Reply

  5. hi all,

    i try the script i was wondering if there was a way to import the server with already groups associated

    Comment by camilo | September 29, 2010 | Reply

  6. camilo: It`s possible to do so, you would need to customize the xml-template.

    Comment by Jan Egil Ring | September 29, 2010 | Reply

    • i tried all get are properties but no group i think I’m doing something wrong. can you give me an example how to modify the XML-Template

      Comment by camilo | September 30, 2010 | Reply

  7. thank you very much,
    is there a way i can modify the XML template so that i can import multiple groups base on the OU structure in AD.

    Comment by camilo | October 1, 2010 | Reply

  8. Hi Jan,

    I modifed the template this way, but i am getting this error:

    You cannot call a method on a null-valued expression.
    At C:\scripts\New-RDCManFile_Quest.ps1:155 char:50
    + $file = (@($xml.RDCMan.file.properties)[0]).Clone <<<< ()
    + CategoryInfo : InvalidOperation: (Clone:String) [],
    RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    a0serverList
    True

    a0servers
    True

    False

    4
    False
    False

    s0serverList
    True

    s0servers
    True

    False

    4
    False
    False

    Comment by FAIZ | October 20, 2010 | Reply

  9. This is certainly a reliable and accurate description of how to manage multiple remote desktop connections at once. But many people who want to do this don’t have the requisite tech background, hence opt for turnkey remote desktop products. What is your feeling on this?

    Comment by tammy messina | December 28, 2010 | Reply

    • Hi, thanks for your feedback.

      Usually I suggest that the script are set up as a scheduled task on a server, so that the config-file are updated i.e. once a day. Then the staff in the IT-department may copy the file from a central file-share whenever they want the latest version containing all servers in the domain. Of course some knowledge on using Windows PowerShell are required to set this up, however, to use the generated config-file there aren`t the need for any PowerShell-knowledge.

      I haven`t tested your product, though it seems nice based on the product overview on your website.

      Comment by Jan Egil Ring | December 28, 2010 | Reply

  10. […] Ring, pointed me to his solution which is a bit more elaborate. Have a look at his solution “Dynamic Remote Desktop Connection Manager connection list“, which is how it really should be […]

    Pingback by Remote Desktop Connection Manager (RDCMan) + Powershell = Win | vNinja.net | January 20, 2011 | Reply

  11. How do you include the password? I tried:

    $group.logonCredentials.Password = “mypasswordhere”

    and also:

    [string]$group.logonCredentials.Password = “mypasswordhere”

    but get:

    Cannot set “password” because only strings can be used as values to set XmlNode properties.

    Comment by Rob | February 4, 2011 | Reply

    • I haven`t tried it, you could have a look at a file where the password are set.

      Comment by Jan Egil Ring | February 7, 2011 | Reply

  12. Has anyone managed to customize the script to create a group for each server OU. I’m using the Quest AD cmdlets.

    Comment by Anthony | April 28, 2011 | Reply

    • I am going to attempt to do this … please let me know if any of you succeed before me

      Comment by Jon Munday | May 11, 2011 | Reply

  13. Has someone been able to modify this script to create group based on Ou where the servers is located ?
    I’m very interested in.

    thx

    Comment by Wilfrid | February 7, 2012 | Reply


Leave a Reply

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

WordPress.com Logo

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: