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

Issue with PS script

ravitejainje
New Contributor
New Contributor

Hi All,

We are trying to execute below JSON, we are getting an error as "Operation not allowed as you are entering a value that resembles or contains script code"

JSON:

{
"accountIdPath": "accountName",
"responseColsToPropsMap": {},
"call": [
{
"name": "call1",
"connection": "acctAuth",
"url": "https://XXXXXXXXXXX/Saviynt/PS/ExecutePSScript",
"httpMethod": "POST",
"httpParams": "{\"Script\": \"\\$pass = convertto-securestring -String '/xxxxxxx}l' -AsPlainText -Force;\\$mycred = new-object -typename System.Management.Automation.PSCredential -argumentlist 'twdev\\\\\\\\SA-Saviynt',\\$pass;\\$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri 'http://XXXXXXXXXXXXXXX/Powershell/' -Credential \\$mycred -Authentication Kerberos -AllowRedirection;Import-PSSession -Session \\$Session -DisableNameChecking -AllowClobber;\\$RemoteMailbox=Enable-RemoteMailbox -Identity '${user.email}' -RemoteRoutingAddress '${user.customproperty19}' -Alias ('${user.customproperty19}'.Split('@')[0]) -erroraction stop; if (\\$RemoteMailbox.PrimarySmtpAddress -ne '${user.email}') {Set-RemoteMailbox -Identity '${user.email}' -PrimarySmtpAddress '${user.email}' -EmailAddressPolicyEnabled \\$false; Set-RemoteMailbox -Identity '${user.email}' -EmailAddresses @{Remove='smtp:\\$(\\$RemoteMailbox.PrimarySmtpAddress)'}; Set-RemoteMailbox -Identity '${user.email}' ${if(null!=user.customproperty29 && !''.equals(user.customproperty29)){return '-EmailAddresses @{Add=\\'' + user.customproperty29 +'\\'}'} else{''}} \"}",
"httpHeaders": {
"Authorization": "Basic xxxxxxxxxxxxxxxxxx"
},
"httpContentType": "application/x-www-form-urlencoded",
"SuccessResponses": {
"": [
"Success"
]
},
"unsuccessResponses": {
"responseMessage": [
"\"Failed\"",
"\"Powershell script taking too long Sample input: Invoke-Command -ComputerName \\\"SAVIYNTADSVCS\\\" -ScriptBlock {command to execute} -Credential $Cred\""
]
}
}
]
}

ravitejainje_0-1716798929101.png

 



1 REPLY 1

rushikeshvartak
All-Star
All-Star

refer https://forums.saviynt.com/t5/tag/WINPS/tg-p


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