Custom PowerShell command for batch edit not working

Custom PowerShell command for batch edit not working

avatar

Greetings, all!

We need to update a large quantity of entries (connections) to now use an SSH Gateway. We exported an XML of a connection that is already set up how we want:

  <ConnectionHandbookPages />
  <Connections>
    <Connection>
      <ConnectionType>SSHShell</ConnectionType>
      <CredentialConnectionSavedPath>Creds\xxxxxxxx</CredentialConnectionSavedPath>
      <Group>xxxxx\xxxxxx</Group>
      <ID>xxxxxxxxxxxxxxxxxxxxx</ID>
      <Name>xxxxxxxxx</Name>
      <OpenEmbedded>true</OpenEmbedded>
      <Stamp>xxxxxxxxxxxxxxxxxx</Stamp>
      <Terminal>
        <EnableLogging>true</EnableLogging>
        <Host>xxxxxxxx</Host>
        <LogFilename>$NAME$-$DATE_TEXT$.txt</LogFilename>
        <LogMode>AllPrintableOutput</LogMode>
        <LogOverwriteMode>Append</LogOverwriteMode>
        <LogPathType>Global</LogPathType>
        <PrivateKeyPromptForPassPhrase>false</PrivateKeyPromptForPassPhrase>
        <SSHGateways>
          <SSHGateway>
            <CredentialConnectionID>xxxxxxxxxxxxxxxxxxxxxxxxx</CredentialConnectionID>
            <CredentialSource>CredentialRepository</CredentialSource>
            <Host>xxxxxxxxxx</Host>
            <ID>xxxxxxxxxxxxxxxxxxxxxxxxx</ID>
            <PrivateKeyConnectionID>xxxxxxxxxxxxxxxxxxxxxxxxx</PrivateKeyConnectionID>
            <PrivateKeyType>Link</PrivateKeyType>
          </SSHGateway>
        </SSHGateways>
        <UseSSHGateway>true</UseSSHGateway>
      </Terminal>
      <TerminalMac />
    </Connection>
  </Connections>
  <DatabaseID>xxxxxxxxxxxxxxxxxxxxxxxxx</DatabaseID>
  <Version>2</Version>
</RDMExport>


Based on the above, we attempted to do this custom PowerShell command as a special action:

$connection.Terminal.PrivateKeyPromptForPassPhrase = "false";
$connection.Terminal.SSHGateways.SSHGateway.CredentialConnectionID = "xxxxxxxxxxxxxxxxxxxxx";
$connection.Terminal.SSHGateways.SSHGateway.CredentialSource = "CredentialRepository";
$connection.Terminal.SSHGateways.SSHGateway.Host = "xxxxxxxxxxxxx";
$connection.Terminal.SSHGateways.SSHGateway.PrivateKeyConnectionID = "xxxxxxxxxxxxxxxxxxxxxx";
$connection.Terminal.SSHGateways.SSHGateway.PrivateKeyType = "Link";
$connection.Terminal.UseSSHGateway = "true";
$RDM.Save();


The result was this output:

xxxxxxxxxxxxxxxx: 
The property 'CredentialConnectionID' cannot be found on this object. Verify that the property exists and can be set.
At line:2 char:1
+ $connection.Terminal.SSHGateways.SSHGateway.CredentialConnectionID =  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo: InvalidOperation: (:) [], RuntimeException
The property 'CredentialSource' cannot be found on this object. Verify that the property exists and can be set.
At line:3 char:1
+ $connection.Terminal.SSHGateways.SSHGateway.CredentialSource = "Crede ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo: InvalidOperation: (:) [], RuntimeException
The property 'Host' cannot be found on this object. Verify that the property exists and can be set.
At line:4 char:1
+ $connection.Terminal.SSHGateways.SSHGateway.Host = "xxxxxxxxxxxx" ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo: InvalidOperation: (:) [], RuntimeException
The property 'PrivateKeyConnectionID' cannot be found on this object. Verify that the property exists and can be set.
At line:5 char:1
+ $connection.Terminal.SSHGateways.SSHGateway.PrivateKeyConnectionID =  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo: InvalidOperation: (:) [], RuntimeException
The property 'PrivateKeyType' cannot be found on this object. Verify that the property exists and can be set.
At line:6 char:1
+ $connection.Terminal.SSHGateways.SSHGateway.PrivateKeyType = "Link";
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo: InvalidOperation: (:) [], RuntimeException


I've done large batch edits using this process before and it's always worked, so I figure I am missing something here. After staring at and troubleshooting this for a little too long I figured I'd see if any fresh, more expert eyes might be able to point me in the right direction.

Attached is also a screenshot of the above output, as well as our running version.

Thank you!

--
Griffeth Barker

--
Griffeth Barker
๐Ÿ’ป Call/Chat on Microsoft Teams
๐Ÿ“ง Send me an email
๐Ÿ”— Connect on LinkedIn

Screenshot 2022-08-31 133733.jpg

Screenshot 2022-08-31 133526.jpg

All Comments (7)

avatar

Hello,

Thank you for reaching out to us regarding this,

Could you provide me a .RDM export of your sample entry? I would like to perform some tests on my end.

Make sure it does not contain any confidential information.

If you prefer I can provide you a link in a private message so that you can send me the export.

Let me know,

Best regards,

Samuel Dery

avatar
Hello,

Thank you for reaching out to us regarding this,

Could you provide me a .RDM export of your sample entry? I would like to perform some tests on my end.

Make sure it does not contain any confidential information.

If you prefer I can provide you a link in a private message so that you can send me the export.

Let me know,

Best regards,


Hi, I'd be happy to provide that export. Would you please provide that link so I don't have to post the RDM file here? Thank you!

--
Griff

--
Griffeth Barker
๐Ÿ’ป Call/Chat on Microsoft Teams
๐Ÿ“ง Send me an email
๐Ÿ”— Connect on LinkedIn

avatar

Hello,

No problem, I've just sent you a private message with the link.

Best regards,

Samuel Dery

avatar
Hello,

No problem, I've just sent you a private message with the link.

Best regards,


Awesome, thank you! I've uploaded the file as requested. Much appreciated,

--
Griff

--
Griffeth Barker
๐Ÿ’ป Call/Chat on Microsoft Teams
๐Ÿ“ง Send me an email
๐Ÿ”— Connect on LinkedIn

avatar

Hello,

Thank you for your patience and for your sample,

I've been doing some tests on my end and I'm wondering if simply using our "Batch Edit" feature would work in your case? We've recently made some changes to this feature which should allow you to use it on SSH Shell entries without any issues.

From testing on my end I did not encounter an issue, could you give it a try on your end?

You can select multiple entries in your "Navigation Pane" then perform a "Right-click" -> "Edit" -> "Batch Edit" -> "Edit Entries (Session Type Settings)" from this point you can go under the "Gateway" tab and select "Override" this will allow you to change the configuration for all selected entries.

I would recommend performing the test on duplicate entries to ensure the result is what you're looking for.

Let me know if this works for you.

Best regards,

Samuel Dery

avatar
Hello,

Thank you for your patience and for your sample,

I've been doing some tests on my end and I'm wondering if simply using our "Batch Edit" feature would work in your case? We've recently made some changes to this feature which should allow you to use it on SSH Shell entries without any issues.

From testing on my end I did not encounter an issue, could you give it a try on your end?

You can select multiple entries in your "Navigation Pane" then perform a "Right-click" -> "Edit" -> "Batch Edit" -> "Edit Entries (Session Type Settings)" from this point you can go under the "Gateway" tab and select "Override" this will allow you to change the configuration for all selected entries.

I would recommend performing the test on duplicate entries to ensure the result is what you're looking for.

Let me know if this works for you.

Best regards,


Okay, we will give that a go. Did not know that the Batch Edit button was useful now as we've always done batch editing using the custom PowerShell commands since Batch Edit used to be fairly restrictive. Thanks for the info! We'll give that a shot.

Appreciate your help.

--
Griff

--
Griffeth Barker
๐Ÿ’ป Call/Chat on Microsoft Teams
๐Ÿ“ง Send me an email
๐Ÿ”— Connect on LinkedIn

avatar

Hello,

Perfect! Let me know if you have further questions,

Best regards,

Samuel Dery