Royal TS And Dynamic Folders

I have been using Royal TS since version 3 of the application. When I opened it up recently I was greeted with a message that the application has been updated to version 5. Well I’m always interested in the newest versions of applications, especially those that I use on a frequent basis, so I started reading the release notes for version 5.

New Icons. Check.

High DPI support. Check

At that point nothing jumped out at me saying that this required a full version update. That is until my eyes landed on the line Dynamic Folders and credentials. This piqued my curiosity so I downloaded version 5 and started looking at the documentation for the new RoyalJSON specification.

Beyond the specifications documentation, there are also examples for all of the supported script interrupters inside of RoyalTS itself. The examples do not show how to dynamically create JSON files but instead show how to create static ones. This is useful for learning how to create your object and is a good first step and a nice welcome example from RoyalTS.

The example provided by Royal for PowerShell shows how to create a credential object, a folder, and a connection to a computer through the terminal.

Using this as the basis with the knowledge of PowerShell I quickly created a script block which queried my test domain for my servers under the Enterprise Servers OU.

Using the example provided by RoyalTS as my guide, I noticed the hash table created by the example script had a key of Objects and the value was the array of computer objects in it. Doing this allows for the JSON output to be formatted correctly for RoyalTS.

Import-Module ActiveDirectory
[System.Collections.ArrayList]$array = @()
foreach ($computer in Get-ADComputer -SearchBase "ou=Enterprise Servers,dc=company,dc=pri" -Filter * -SearchScope subtree -Properties canonicalname)
{
    $array.add((
            New-Object -TypeName System.Management.Automation.PSObject -Property @{
                "Type" = "RemoteDesktopConnection";
                "Name" = $computer.name;
                "ComputerName" = $computer.name;
                "credentialName" = "mikes";
                "Path" = $computer.canonicalname.replace("/$($computer.name)", "")
            }
        )) | Out-Null
}
$array = $array | Sort-Object -Property path
$hash = @{ }
$hash.add("Objects", $array)
$hash | ConvertTo-Json

Something I found (and didn’t see documented - or maybe I missed it) is that RoyalTS will automatically create the full path for a computer object for you if you put the computer in a path that does not exist. In the case of my script - I am putting the computer in the same folder as it is found in Active Directory and RoyalTS is automatically creating the folder path for me without me having to define it first.

Annotation 2018-12-22 190023.jpg

Notice that the two folder structures match. The OU TestOU is not present in RoyalTS since no computer is defined under there - which is a result of my code and not RoyalTS. If I had written code to first generate the OU structure based on Get-ADOrganizationalUnit the items would indeed have been present in the OU list in RoyalTS.

By using the properties defined in the RoyalJSON specification, we are able to set the credentials that each connection uses either by name, id or explicitly. In the below video, I go over how to create a RoyalTS dynamic folder and shows that it can query AD to create a dynamic list of connections.

Work Philosophy - Part 1/10

While coming back from the Global Powershell & DevOps summit in April of 2016, I had a chance to think about HOW I perform my job currently, and HOW I want to be performing it eventually, and what are the items that get me there. This ultimately became my philosophy of work, and maybe this will spur you on to think about how you do the work that you do daily.

Read More