05/11/2023 06:01 AM
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:
Thank you!
05/19/2023 07:46 AM
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