Saviynt unveils its cutting-edge Intelligence Suite products to revolutionize Identity Security!
Click HERE to see how Saviynt Intelligence is transforming the industry.
Saviynt Copilot Icon

Error while executing powershell script via REST connection

nvachhani
Regular Contributor II
Regular Contributor II

We are calling an existing script with some arguments on the IIS Server. Hardcoding values executes the script but with variables it does not work, either it thinks value is null or is not resolving the variable. Have tried backslashes to escape quotes but no luck. Below is the createaccountJSON:

 

{
    "accountIdPath": "accountName",
    "responseColsToPropsMap": {},
    "call": [
        {
            "name": "call1",
            "connection": "userAuth",
            "url": "http://xx.xx.xx/SaviyntApp/PS/ExecutePSScript",
            "httpMethod": "POST",
            "httpParams": "{\"Script\": \"F:\/scripts\/MailEnableUser.ps1 '${userName}' '${password}' '${user.email}' '${task.accountName}' \"}",
            "httpHeaders": {
                "Authorization": "${access_token}"
            },
            "httpContentType": "application/x-www-form-urlencoded",
            "SuccessResponses": {
                "statusCode": [
                    200
                ]
            },
            "unsuccessResponses": {
                "statusCode": [
                    400,
                    401,
                    404,
                    405,
                    500
                ]
            }
        }
    ]
}

 

6 REPLIES 6

rushikeshvartak
All-Star
All-Star

Replace username to user.username


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

nvachhani
Regular Contributor II
Regular Contributor II

Actually that is the username and password from connection JSON not the user's. Issue seems in general with the variables, syntax is wrong for some reason but we cannot determine where.

Connection json ?

then it should be ${connection.username}


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

nvachhani
Regular Contributor II
Regular Contributor II
{
  "authentications": {
    "userAuth": {
      "authType": "Basic",
      "url": "http://xx.xx.xx.corp/SaviyntApp/PS/ExecutePSScript",
      "httpMethod": "POST",
      "httpParams": {},
      "httpHeaders": {},
      "httpContentType": "text/html",
      "properties": {
        "userName": "xx",
        "password": "xx"
      },
      "expiryError": "ExpiredAuthenticationToken",
      "authError": [
        "InvalidAuthenticationToken",
        "AuthenticationFailed"
      ],
      "timeOutError": "Read timed out",
      "errorPath": "error.code",
      "maxRefreshTryCount": 5,
      "tokenResponsePath": "access_token",
      "tokenType": "Basic",
      "accessToken": "Basic xxx",
      "testConnectionParams": {
        "http": {
          "url": "http://xx.xx.xx.corp/SaviyntApp/PS/ExecutePSScript",
          "httpMethod": "POST",
          "requestBody": "",
          "httpParams": {},
          "httpHeaders": {
            "contentType": "application/json",
            "Authorization": "${accessToken}"
          },
          "httpContentType": "application/json"
        },
        "successResponse": [],
        "successResponsePath": "responseText",
        "errors": [
          "fail",
          "error",
		  "false"
        ],
        "errorPath": "responseText"
      }
    }
  }
}

 

Using ${connection.username} does not work, getting a username/password error there. Looks like ${userName} and ${password} work, but ${user.email} and ${task.accountName} is causing the error. I have attached the error.

 

nvachhani
Regular Contributor II
Regular Contributor II

This was resolved by using the following variables instead of ${userName} and ${password} or ${connection.username} and ${connection.password}:

'${connection.exchUser}' '${connection.exchPassword}'

I have mentioned same thing


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.