Announcing the Saviynt Knowledge Exchange unifying the Saviynt forums, documentation, training,
and more in a single search tool across platforms. Read the announcement here.

Using REST conn to run PS Script, task closes but looks like script doesn't execute?

jralexander137
New Contributor II
New Contributor II

Hi, I am having an issue where I am using the REST connection and updatesUserJson in there to make a rest call to the saviynt app on a windows server to execute some powershell script. Test Connection works and I am able to trigger the script using the following body in postman:

{
"Script": "cd E:/; powershell .\\TestMailboxProvisioning3.ps1 babzshim"
}

The problem I am seeing is that in Saviynt, the task gets generated, I run the prov job, the task closes but best I can tell the script never executes. No error or response is returned from the script like I get in postman, or if one is returned the connection isn't parsing it and putting it in the logs. 

I am truly at a loss here since I have no meaningful error or response to troubleshoot off. Here are my connectionJson and updateUserJson:

Maybe my response configs are incorrect? I have tried several variations and I have a write-output command in the script to output "Mailbox Created" only if it actually gets created. Plus I would assume if this is coming in the repsonse I would see it in the logs which I am now.

{
"accountIdPath": "accountName",
"responseColsToPropsMap": {},
"call": [{
"name": "call1",
"connection": "userAuth",
"showResponse": true,
"url": "https://saviyntwinpsdev.rob.com/SaviyntDev_WinPS/PS/ExecutePSScript",
"httpMethod": "POST",
"httpParams": "{\"Script\":\"cd E:/; powershell .\\TestMailboxProvisioning3.ps1 ${user.systemUserName} \"}",
"httpHeaders": {
"Authorization": "${access_token}",
"Accept": "application/json"
},
"httpContentType": "application/x-www-form-urlencoded",
"successResponses":[
{
"message": "Mailbox Created"
}
],
"unsuccessResponses": {
"response.StatusCode": "1"
}
}]
}

{
"authentications": {
"userAuth": {
"authType": "Basic",
"url": "https://saviyntwinpsdev.rob.com/SaviyntDev_WinPS/PS/ExecutePSScript",
"httpMethod": "POST",
"httpParams": {},
"httpHeaders": {
"Accept": "application/json"
},
"httpContentType": "application/json",
"properties": {
"userName": "domain\\username",
"password": "password"
},
"expiryError": "ExpiredAuthenticationToken",
"authError": [
"InvalidAuthenticationToken",
"AuthenticationFailed",
"Authentication_MissingOrMalformed",
"Authentication_ExpiredToken"
],
"retryFailureStatusCode": [
403,
401,
500
],
"timeOutError": "Read timed out",
"errorPath": "errors.code",
"maxRefreshTryCount": 5,
"tokenResponsePath": "token",
"tokenType": "Basic",
"accessToken": "Basic abcd"
}
}
}

I am at a loss as to what I'm missing here. The body works in postman which means it should work here and if not...why am I not getting any errors or response results to work with?

4 REPLIES 4

rushikeshvartak
All-Star
All-Star

In file path blackslash missing 

references https://forums.saviynt.com/t5/identity-governance/mailbox-provisioning-access-denied-error/m-p/38759


Regards,
Rushikesh Vartak
If you find the response useful, kindly consider selecting Accept As Solution and clicking on the kudos button.

I modified it as you mentioned

"httpParams": "{\"Script\":\"cd E:\/; powershell .\\TestMailboxProvisioning3.ps1 ${user.systemUserName} \"}",

 

Tried this variation as well:

{
"accountIdPath": "accountName",
"responseColsToPropsMap": {},
"call": [
{
"name": "call1",
"connection": "userAuth",
"url": "https://saviyntwinpsdev.rob.com/SaviyntDev_WinPS/PS/ExecutePSScript",
"httpMethod": "POST",
"httpParams": "{\"Script\":\"cd E:\\\\; powershell .\\\\TestMailboxProvisioning3.ps1 ${user.systemUserName}\"}",
"httpHeaders": {
"Authorization": "${access_token}",
"Accept": "application/json"
},
"httpContentType": "application/json",
"successResponses": {
"message": "Mailbox Created",
"statusCode": [200]
},
"unsuccessResponses": {
"statusCode": [400, 500, 401, null]
}
}
]
}

Still seeing the task close but no error or response in the logs. Mailbox not being generated. Here is the full updated config:

{ "accountIdPath": "accountName", "responseColsToPropsMap": {}, "call": [{ "name": "call1", "connection": "userAuth", "showResponse": true, "url": "https://saviyntwinpsdev.rob.com/SaviyntDev_WinPS/PS/ExecutePSScript", "httpMethod": "POST", "httpParams": "{\"Script\":\"cd E:\/; powershell .\\TestMailboxProvisioning3.ps1 ${user.systemUserName} \"}", "httpHeaders": { "Authorization": "${access_token}", "Accept": "application/json" }, "httpContentType": "application/json", "successResponses":{"message": "Mailbox Created", "statusCode": [200] }, "unsuccessResponses": {"statusCode": [ 400, 500, 401, null ] } }] }

Logs showing no response, payloads look fine I think:

"2024-01-07T20:41:43.945+00:00","ecm-worker","rest.RestProvisioningService","quartzScheduler_Worker-5-2wvft","DEBUG","updateUserJSON: [accountIdPath:accountName, responseColsToPropsMap:[:], call:[[name:call1, connection:userAuth, url:https://saviyntwinpsdev.rob.com/SaviyntDev_WinPS/PS/ExecutePSScript, httpMethod:POST, httpParams:{"Script":"cd E:\\; powershell .\\TestMailboxProvisioning3.ps1 ${user.systemUserName}"}, httpHeaders:[Authorization:${access_token}, Accept:application/json], httpContentType:application/json, successResponses:[message:Mailbox Created, statusCode:[200]], unsuccessResponses:[statusCode:[400, 500, 401, null]]]]]"
"2024-01-07T20:41:43.945+00:00","ecm-worker","rest.RestProvisioningService","quartzScheduler_Worker-5-2wvft","DEBUG","User for which the loop is running:4939342"
"2024-01-07T20:41:43.945+00:00","ecm-worker","rest.RestProvisioningService","quartzScheduler_Worker-5-2wvft","DEBUG","Tasks to work on = 1"
"2024-01-07T20:41:43.945+00:00","ecm-worker","rest.RestProvisioningService","quartzScheduler_Worker-5-2wvft","DEBUG","Action to be performed =null"
"2024-01-07T20:41:43.945+00:00","ecm-worker","rest.RestProvisioningService","quartzScheduler_Worker-5-2wvft","DEBUG","updateUserActionResponse : true"
"2024-01-07T20:41:43.945+00:00","ecm-worker","services.ArsTaskService","quartzScheduler_Worker-5-2wvft","DEBUG","Entering provisionAccesstoAccountSaviynt"
"2024-01-07T20:41:43.945+00:00","ecm-worker","services.ArsTaskService","quartzScheduler_Worker-5-2wvft","DEBUG","{4939342=[com.saviynt.ecm.task.ArsTasks : 168]}"
"2024-01-07T20:41:43.945+00:00","ecm-worker","services.ArsTaskService","quartzScheduler_Worker-5-2wvft","DEBUG","UPDATEUSER"
"2024-01-07T20:41:43.945+00:00","ecm-worker","services.ArsTaskService","quartzScheduler_Worker-5-2wvft","DEBUG","Processing task 168 start"
"2024-01-07T20:41:43.946+00:00","ecm-worker","services.ArsTaskService","quartzScheduler_Worker-5-2wvft","DEBUG","completing task = 168"
"2024-01-07T20:41:43.946+00:00","ecm-worker","services.ArsTaskService","quartzScheduler_Worker-5-2wvft","DEBUG","completing task = 168 done"

I went all the way up to 8 backslashes based on various examples I came across. Still experiencing the same issue.

{
"accountIdPath": "accountName",
"responseColsToPropsMap": {},
"call": [
{
"name": "call1",
"connection": "userAuth",
"url": "https://saviyntwinpsdev.rob.com/SaviyntDev_WinPS/PS/ExecutePSScript",
"httpMethod": "POST",
"httpParams": "{\"Script\":\"cd E:\\\\\\\\; powershell .\\\\\\\\TestMailboxProvisioning3.ps1 ${user.systemUserName}\"}",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType": "application/x-www-form-urlencoded",
"successResponses": {
"message": "Mailbox Created",
"statusCode": [200]
},
"unsuccessResponses": {
"statusCode": [400, 500, 401, null]
}
}
]
}

I wonder if maybe the issue lies with the connection JSON? I tried modifying the http params as in the config below. It just creates a file on the server if the script is run. Tested the command i am passing on the server and via postman, both work. Not getting any error and this test connection config says successful when hitting the test connection in Sav. But the file is NOT getting created so I don't think its successful test connection.

{
"authentications": {
"userAuth": {
"authType": "Basic",
"url": "https://saviyntwinpsdev.rob.com/SaviyntDev_WinPS/PS/ExecutePSScript",
"httpMethod": "POST",
"httpParams": "{\"Script\":\"E:/testing5.ps1\"}",
"httpHeaders": {
"Accept": "application/json"
},
"httpContentType": "application/json",
"properties": {
"userName": "username",
"password": "password"
},
"expiryError": "ExpiredAuthenticationToken",
"authError": [
"InvalidAuthenticationToken",
"AuthenticationFailed",
"Authentication_MissingOrMalformed",
"Authentication_ExpiredToken"
],
"retryFailureStatusCode": [
403,
401,
500
],
"timeOutError": "Read timed out",
"errorPath": "errors.code",
"maxRefreshTryCount": 5,
"tokenResponsePath": "token",
"tokenType": "Basic",
"accessToken": "Basic abcd"
}
}
}