Custom (PowerShell) synchronizer entry

This entry is a powerful "hybrid" synchronizer that lets you use PowerShell scripts to populate vaults, sync descriptions, apply templates and more. You can synchronize from sources that we don’t have a dedicated synchronizer for. It leverages proxy classes to interact with rich Remote Desktop Manager connection objects.

Custom (PowerShell) synchronizer use cases

Simple session

Provide the host, name, description and group while using the default RDP type. Alternatively, use a template to promote reuse and standardization. Here is an example:

# obtain or generate your list of sessions to create, here we assume a $data table
# has been filled by querying an external source.
Foreach($row in $data)
{
  # create a new session, the only mandatory property is 'Name' so we require it as a parameter in the Add method
  $session = $RDM.Add($row.Name)
  # set the other properties using $session.<property>
  $session.Host = $row.Name
  $session.Description = $row.Description
  $session.Group = $row.Group # it can be multiple levels i.e. 'Folder1\Folder1a'
}

Session with credentials

To set the credentials, use: $session.SetCredentials($row.Username, $row.Password, $row.Domain);.

To only set the password, use: $session.SetPassword($row.Password);.

The password cannot be set using $session.Password.

Commonly used fields

Here are commonly used fields for quick reference:

string CustomStatus
string Description
bool Encrypt
string Group
string Host
bool IncludeInFavorite
string Name
bool OpenEmbedded
bool ShowInTrayIcon
int SortPriority
<Color>#FF0000</Color>
string GroupTab
string Status
string TabTitle

Advanced scenario

By using the method outlined in Reverse engineering an entry's structure, you can create an entry with all required information in the appropriate fields and observe how to assign values using PowerShell.

For example, here is a Host entry for which many fields of the ViewAsset section have been filled:

<?xml version="1.0" encoding="utf-8"?>
<ArrayOfConnection>
  <Connection>
    <AppVersion>~SET AUTOMATICALLY~</AppVersion>
    <Color>#FF0000</Color>
    <ConnectionType>Host</ConnectionType>
    <CreatedBy>~SET AUTOMATICALLY~</CreatedBy>
    <CreationDateTime>~SET AUTOMATICALLY~</CreationDateTime>
    <Description>phDescription</Description>
    <GroupTab>phTabGroupName</GroupTab>
    <ID>~SET AUTOMATICALLY~</ID>
    <Name>phName</Name>
    <OpenEmbedded>true</OpenEmbedded>
    <SortPriority>100</SortPriority>
    <Status>{123A44CB-7EDC-4ecb-926B-031793668148}</Status>
    <TabTitle>phTabPageTitle</TabTitle>
    <HostDetails>
      <Host>phName</Host>
    </HostDetails>
    <MetaInformation>
      <AssetSubType>Desktop</AssetSubType>
      <Domain>metadomain</Domain>
      <IP>metaIP</IP>
      <Keywords>MyTag1</Keywords>
      <MAC>metamac</MAC>
      <MachineName>metaHost</MachineName>
      <NetworkDHCPRange>MetaDHCPRange</NetworkDHCPRange>
      <NetworkDHCPServer>MetaDHCPServer</NetworkDHCPServer>
      <NetworkFirewallZone>MetaFirewall</NetworkFirewallZone>
      <NetworkGateway>MetaGateway</NetworkGateway>
      <NetworkIPRange>metaIPRange</NetworkIPRange>
      <NetworkSubnet>metaSubnet</NetworkSubnet>
      <NetworkVLANID>MetaVlan</NetworkVLANID>
      <OS>metaos</OS>
    </MetaInformation>
  </Connection>
</ArrayOfConnection>

You can see a few "complex" objects, namely HostDetails and MetaInformation. The former is specific to the Host entry type, and the latter is a container for everything in the ViewAsset section. Add the section name as a prefix to write to the inner fields.

Foreach($row in $data)
{
  $session = $RDM.Add($row.Name)
  $session.Kind = "Host"
  $session.HostDetails.Host = $row.Name
  $session.MetaInformation.AssetSubType = "Desktop"
  $session.MetaInformation.IP = "10.10.1.25"
}

Key points

  • Note that Name and HostDetails.Host properties share the same value. This is a characteristic of the Host entry, and caution must be taken when working with other entry types as well.

  • Some fields, like MetaInformation.AssetSubType are tied to an enumeration and must contain the exact string. Some others like MetaInformation.NetworkGateway are simple strings and can contain anything. Therein lies the challenge of looking at the XML. Feel free to contact our support team if you have further questions.

Devolutions Forum logo Give us Feedback