Start a new topic
Solved

Creating script Parameters in Powershell connector using dynamic folders

I am trying to create a powershell connector with a dynamic folder.

I already have the code available to retrieve credentials dynamically.

I have also successfully created the connector using a raw jSON connector.


I need to create 2 script paramters but the documentation is not clear on the syntax and I could not find an example in the repo.


I know the snippet below works when I created it in my raw jSON format.

I manually created the Parameters in the second tab and mapped those 2 parameters to the $EffectiveUsername$ and $EffectivePassword$ tokens.

And then I went to the Test tab and tested successfully.


"Script": "#Get RoyalTS Creds

param (

 [string] $userdn,

 [string] $userpw

 )


$user = $uid

$userpass = $userpw

.....


However when I referred to the online documentation

https://docs.royalapps.com/r2021/scripting/objects/connections/royalpowershellconnection.html#parameters


Parameters

Type: string, Default Value: Empty String
The script parameters to pass on to the script.


It does not provide any sample syntax. Most of the parameters in the doco are clear, for example:

"Script" : "# powershell code......."

It is only the parameter and a value.

And I have figured out how to format extended Properties into a block.


However, the Parameters are a series of custom_parameter_name and parameter_Value grouped in the Parameters section of the Powershell-> Script block. I have tried multiple varieties of syntax of formatting but without a reference, it is impossible to script this key part of my script.


Thank you


Hi!


you can specify the script parameters using a simple XML encoded string. Here's an example:


Line 4 to 18 in the screenshot above shows the XML which is expected by Royal TS/X. 

Line 1 shows the actual property value as XML encoded string.


You can create the following XML:

<?xml version="1.0" encoding="utf-16">
<ParamConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <ParamConfigItems>
        <ParamConfigItem>
            <ParameterName>Param1</ParameterName>
            <Value>$EffectiveUsername$</Value>
            <TestValue />
        </ParamConfigItem> 
        <ParamConfigItem>
            <ParameterName>Param2</ParameterName>
            <Value>Some Value</Value>
            <TestValue />
        </ParamConfigItem>
    </ParamConfigItems>
</ParamConfig>


Set this XML as XML encoded string to the Parameters property as described in the Advanced Scenarios topic:

https://docs.royalapps.com/r2021/scripting/rjson/advanced-scenarios.html


I hope this helps. I will also include the XML sample in the docs.


Regards,
Stefan


Did you find a solution to your problem?  I have the same issue.

Login or Signup to post a comment