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

How to get value in response from WINPS?

luka_harabajsa
New Contributor III
New Contributor III

Hi,

We are executing Powershell scripts from Saviynt on WINPS. Scripts are executed, everything is OK on that part, but when we want to return something from the script, we are only getting the length of the response string.

For example, we want to return email from the account name which is used as input parameter.

We are  invoking request through Powershell on the server and sending it to our WINPS endpoint.

This is test script where we are taking account name as parameter and returning account name:

--------------------------------------------------------------------------------------------

param(
[Parameter()]
[string]$AccountName = 'test1'
)

$customObject = New-Object -TypeName PSObject  

$customObject | Add-Member -MemberType NoteProperty -Name accountName -Value $AccountName 

$customObject

-----------------------------------------------------------------------------

This is Invoke-RestMethod part:

$Body = @{SCRIPT = "
Powershell.exe C:\Saviynt\PowershellScripts\test.ps1
"}

Invoke-RestMethod https://xxxxxx.xxxxx.net/saviynt/PS/ExecutePSScript -Method Post -Body $Body

Response:

luka_harabajsa_0-1683809925852.png

Thank you!

 

 

1 REPLY 1

Darshanjain
Saviynt Employee
Saviynt Employee

Hi @luka_harabajsa 

Can you please give us more details

1.Are you able to get the response when you directly run in the server and see if you are able to get the response.

2. What attribute you want it as response and where do you want to store it ( may be  a business justification can help us )

Meanwhile we will check how we can store a response from the script as well

 

Thanks

Darshan