Tips & Tricks
Max Trottier

Maxime has extensive experience in product management, communication and advertising, and has spent the last several years helping renowned organizations bring their high-end solutions to customers worldwide. As Director of Marketing, Maxime leads Devolutions’ international market research and development efforts, along with customer relations and overall business development. He’s driven to bring innovative and cutting-edge solutions to Devolutions’ customers around the globe. Maxime earned his Bachelor degree in Business Administration from the University of Québec at Trois-Rivières, and regularly attends sales and marketing workshops to increase his knowledge and expertise.

Windows PowerShell: Remote Desktop Manager Automation

![](https://webdevolutions.blob.core.windows.net/blog/2013/01/powershell1-300x160.jpg) Did you know that RDM has a Windows PowerShell snap-in? It was part of RDM 7.0, which was released early last year. The RDM snap-in allows for quick and robust automation of actions, such as add/edit/open of sessions. The possibilities are endless, and are limited only by your imagination – and, of course, the tool’s functionality (use the forum to suggest new functionality!).

Since its release, this highly-requested feature has become a very useful in solving user requests. A quick search through our forum reveals many ingenious usages of the cmdlets, such as automating the creation of Windows Start Menu shortcuts for every RDM session (link).

To learn more, you can find full RDM cmdlet documentation available via online help, or directly in PowerShell using the ** Get-Help** cmdlet.

Example: Create Web Data Entry

![](https://webdevolutions.blob.core.windows.net/blog/2013/01/screenshot2.png)

Here’s a simple example of the RDM PowerShell snap-in at work. We’ll be covering how I imported all blog URLs from Google Reader.

  1. I started by exporting my Google Reader subscriptions (via Google Takeaway).

  2. Next, I loaded the file into an XmlDocument using Get-Content.

  3. Finally, I created an RDM session for each node, and assigned the appropriate properties:

[xml]$rss = Get-Content C:rss.xml;

``

foreach ($site in $rss.opml.body.outline)

{

$session = New-RDM-Session -Name $site.Text -Kind "DataEntry"

$session.Group = "RSS"

$session.AddDataEntryKind(11 <# Web #>);

Set-RDM-Session $session -NoRefresh;

Set-RDM-Property -ID $session.ID -Path "DataEntry" -Property "Url" -Value $site.htmlUrl

}

``

Example: Reflect the group name as the company name

foreach ($list in Get-RDM-Session)

{

$group = Get-RDM-Property -id $list.id -Property "Group";

Set-RDM-Property -ID $list.ID -Path "MetaInformation" -Property "Company" -value $group -NoRefresh

}

Now, for you IT pros out there, this is a pretty simple example that you could do in your sleep! However, I merely wanted to illustrate how robust the feature is, and how you can use it to make your life easier and more productive.

Additional tips

Here are some additional tips to help you get the most out of the PowerShell snap-in:

  • Use the –NoRefresh flag for faster script execution, especially in loops, since the UI isn’t refreshed during the action.

  • Use the Set-RDM-Property cmdlet to set almost any value within the session object. To find properties and paths, reverse engineer the session XML file format. Create a sample session in RDM and export it using the right click menu Import/Export -> Export Session (.rdm).... Once exported, open the .rdm file with your favorite editor. Browse the XML structure to find the property path and name.

  • Use the AddDataEntryKind method to set the data entry kind to Web (11 in this case). This is not actually documented – it’s just a bonus tip that we use here at Devolutions all the time!

So, how would you find more helpful tips like these? Simply visit our forum and ask! Plus, if the tool can’t do what you need it to, we’ll see what we can do to add it to a future release. In fact, most of the features we’ve built so far are a result of user requests for help and guidance.

Conclusion

As you can see, RDM PowerShell integration can be very useful – and the full potential hasn’t yet been tapped! If you have an interesting PowerShell script, or would like to see more examples, please comment below.

Related Posts

Read more Tips & Tricks posts