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

Testing if REST Connector initiates Powershell script in Windows Server

plana77
New Contributor III
New Contributor III

Hi!

Can i use CreateAccountJSON to initiate Powershell in Target Windows Server, which is only writing one word in Notepad in Windows Server? 

{
"accountIdPath":"accountName",
"responseColsToPropsMap":{
},
"call":[
{
"name":"call",
"connection":"auth",
"url":"https://xx.xx.xx.x:443/SaviyntApp/PS/ExecutePSScript",
"httpMethod":"POST",
"httpParams":"{\"Script\":\"cd C:\\\\\\\\IDM;.\\\\\\\\test.ps1\"}",
"httpHeaders":{
"Authorization":"${access_token}"
},
"httpContentType":"application/x-www-form-urlencoded",
"SuccessResponses":{
"":["Success"]
},
"unsuccessResponses":{
"":["Failed"]
}
}
]
}

I tried to do testing in Connection JSON, but Connection Test is failing when i have testConnectionParam included into it?

{
"authentications":{
"auth":{
"authType":"basic",
"maxRefreshTryCount":5,
"properties":{
"userName":">username<",
"password":">password<"},
"authError":["InvalidAuthenticationToken","AuthenticationFailed"],
"retryFailureStatusCode":[401],
"testConnectionParams": {
"http": {
"url":"https://>ComputerName<.com/SaviyntApp/PS/ExecutePSScript",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType":"application/x-www-form-urlencoded",
"httpMethod": "POST",
"httpParams": "{\"Script\":\"C:\\\\\\\\IDM;.\\\\\\\\test.ps1\"}"
}
}
}
}
}

 

8 REPLIES 8

rushikeshvartak
All-Star
All-Star

https://saviynt.freshdesk.com/support/solutions/articles/43000521736-rest-connector-guide%C2%A0 

Refer Example 6 


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

Hi! So this file in Example 6 >PSScript.ps1 can  have any content e.g. it executes Powershell script that writes something in file? I am not trying to create Account in this example, but only testing if REST call will initiate powershell script in Windows Server?

 

You can have any script in powershell .ps1


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

plana77
New Contributor III
New Contributor III

Hi!

When i run CreateAccountJSON

{
"accountIdPath":"accountName",
"responseColsToPropsMap":{
},
"call":[
{
"name":"call",
"connection":"auth",
"url":"https://xx.xx.xx.x:443/SaviyntApp/PS/ExecutePSScript",
"httpMethod":"POST",
"httpParams":"{\"Script\":\"cd C:\\\\\\\\IDM;.\\\\\\\\test.ps1\"}",
"httpHeaders":{
"Authorization":"${access_token}"
},
"httpContentType":"application/x-www-form-urlencoded",
"SuccessResponses":{
"":["Success"]
},
"unsuccessResponses":{
"":["Failed"]
}
}
]
}

I get this as response 

"call":{"headers":{"Server":"Microsoft-HTTPAPI/2.0","Connection":"close","Content-Length":"315","Date":"Tue, 27 Sep 2022 18:09:03 GMT","Content-Type":"text/html; charset=us-ascii"},"statusCode":404,"description":null,"status":"Failed"}}

Does it mean that it can not find file from location?

Try hardcoding of Authorization token


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

plana77
New Contributor III
New Contributor III

Hi!

I got SSL certificate as Public in base64 format .cer.  in Developers handbook it is said that it should be enough to make API calls.

Are you able to make api call from postman, if yes share screenshot


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

plana77
New Contributor III
New Contributor III

Hi! I can not access Production Win Server with Postman. 

But i am getting error of this ConnectionJSON, issue might be that we do not have connectivity from SC 2.0 towards Windows server via port 443, i have a ticket about this.

{
"authentications": {
"auth": {
"authError": [
"InvalidAuthenticationToken",
"AuthenticationFailed"
],
"authType": "basic",
"maxRefreshTryCount": 1,
"properties": {
"password": "xxxxxxxxxxxxxxxxxxx",
"userName": "domain\username"
},
"retryFailureStatusCode": [
401
],
"testConnectionParams": {
"http": {
"url": "https://xx.xx.xx.x/SaviyntApp/PS/ExecutePSScript",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType":"application/x-www-form-urlencoded",
"httpMethod": "POST",
"httpParams": "{\"Script\":\"SCRIPT=Test-NetConnection xx.xx.xx.x -Port 443\"}"
}
}
}
}
}

Error While Test connection: JSON syntax exception found in the following connection parameters - ConnectionJSON

i thing this might be causing it: "userName": "domain\username"

i know that this works(userName": "domain\username) in upper Saviynt versions that we have 

for some other customers, why it does not work here?

We have version: Release-2021.0.4.7

Best Regards,Päivi