and more in a single search tool across platforms. Read the announcement here. |
01/25/2024 11:22 PM - last edited on 01/26/2024 01:47 AM by Sunil
Hi Team,
Help us to get proper syntax to pass ${user.username} and ${connection.username} , ${connection.password}.
Below is the JSON :
{
"call": [
{
"name": "call1",
"connection": "acctAuth",
"url": "http://******-savutil01.gaworkdaytest.local/SaviyntApp/PS/ExecutePSScript ",
"httpMethod": "POST",
"httpParams": "{\"script\":\" \u0024name= \u0027\u0024{user.username}\u0027; \u0024cred = New-Object System.Management.Automation.PSCredential -argumentlist \u0027test\\\\user\u0027, (ConvertTo-SecureString \u0027samplepassword\u0027 -AsPlainText -Force); \u0024onprem = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionURI http://hostname/PowerShell/ -Credential \u0024cred; Invoke-Command -Session \u0024onprem -scriptBlock {Enable-RemoteMailbox u002DIdentity \u0024using:name -RemoteRoutingAddress \u0024using:name\u0027@domain.com\u0027} \"}",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType": "application/json",
"successResponses": {
"response[9].Objectreturned": [
"Success"
]
},
"unsuccessResponses": {
"response[9].Objectreturned": [
"Failure"
]
}
}
]
}
I saw in document there is unicode value for ' - \u0027 and $ - \u0024.
Getting below issue :
{"headers":null,"message":{"responseMessage":"\"Exception: Failed error streamThe operation couldn\\u0027t be performed because object \\u0027${user.username}\\u0027 couldn\\u0027t be found on \\u0027TMUE1-DC01.GAWORKDAYTEST.local\\u0027. System.Exception: Failed error streamThe operation couldn\\u0027t be performed because object \\u0027${user.username}\\u0027 couldn\\u0027t be found on \\u0027TMUE1-DC01.GAWORKDAYTEST.local\\u0027.\\r\\n at MVC_FIM.Services.PowerShellService.fnExecuteScript(String ScriptName) System.Exception: Failed error streamThe operation couldn\\u0027t be performed because object \\u0027${user.username}\\u0027 couldn\\u0027t be found on \\u0027TMUE1-DC01.GAWORKDAYTEST.local\\u0027. System.Exception: Failed error streamThe operation couldn\\u0027t be performed because object \\u0027${user.username}\\u0027 couldn\\u0027t be found on \\u0027TMUE1-DC01.GAWORKDAYTEST.local\\u0027.\\r\\n at MVC_FIM.Services.PowerShellService.fnExecuteScript(String ScriptName)\\r\\n at MVC_FIM.Services.PowerShellService.fnExecuteScript(String ScriptName)\""},"statusCode":500,"description":null,"status":"Failed"},{"headers":null,"message":{"responseMessage":"\"Exception: Failed error streamA positional parameter cannot be found that accepts argument \\u0027$null\\u0027. System.Exception: Failed error streamA positional parameter cannot be found that accepts argument \\u0027$null\\u0027.\\r\\n at MVC_FIM.Services.PowerShellService.fnExecuteScript(String ScriptName) System.Exception: Failed error streamA positional parameter cannot be found that accepts argument \\u0027$null\\u0027. System.Exception: Failed error streamA positional parameter cannot be found that accepts argument \\u0027$null\\u0027.\\r\\n at MVC_FIM.Services.PowerShellService.fnExecuteScript(String ScriptName)\\r\\n at MVC_FIM.Services.PowerShellService.fnExecuteScript(String ScriptName)\""},"statusCode":500,"description":null,"status":"Failed"}]},"call1":{"headers":null,"message":{"responseMessage":"\"Exception: Failed error streamA positional parameter cannot be found that accepts argument \\u0027${user.username}\\u0027. System.Exception: Failed error streamA positional parameter cannot be found that accepts argument \\u0027${user.username}\\u0027.\\r\\n at MVC_FIM.Services.PowerShellService.fnExecuteScript(String ScriptName) System.Exception: Failed error streamA positional parameter cannot be found that accepts argument \\u0027${user.username}\\u0027. System.Exception: Failed error streamA positional parameter cannot be found that accepts argument \\u0027${user.username}\\u0027.\\r\\n at MVC_FIM.Services.PowerShellService.fnExecuteScript(String ScriptName)\\r\\n at MVC_FIM.Services.PowerShellService.fnExecuteScript(String ScriptName)\""},"statusCode":500,"description":null,"status":"Failed"}}
[This message has been edited by moderator to disable url hyperlink]
01/26/2024 06:07 AM
Share connection json
01/26/2024 09:44 AM
Hi,
In case $ is used within single quotes, you may not have to use the unicode value.
Please try with the below:-
"httpParams": "{\"script\":\" \u0024name = '${user.username}'; \u0024cred = New-Object System.Management.Automation.PSCredential -argumentlist 'test\\\\user', (ConvertTo-SecureString 'samplepassword' -AsPlainText -Force); \u0024onprem = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionURI http://hostname/PowerShell/ -Credential \u0024cred; Invoke-Command -Session \u0024onprem -scriptBlock {Enable-RemoteMailbox u002DIdentity \u0024using:name -RemoteRoutingAddress \u0024using:name'@domain.com'} \"}",
This may be a possibility for the syntax error.
01/27/2024 06:58 AM
Thank you, Shreya.
Now that issue is resolved but new issue arises-
And I think this is because we are initializing the variable $name but using the variable $using:name so the Saviynt is not able to find the usage of $name variable.,
If rather than using $using:name I am trying to use $name then following exception is thrown-
01/27/2024 08:56 AM
Did you defined username & password variables on connection JSON
01/27/2024 10:37 AM
Hi Rushikesh,
Yes, Like this-
01/27/2024 12:15 PM
You need to define outside similar like accesstoken. You can share connection json ( masking confidential info) i can help you
01/27/2024 12:21 PM
Sample
{
"authentications": {
"userAuth": {
"authType": "Basic",
"url": "http://xx.xx.xx.corp/SaviyntApp/PS/ExecutePSScript",
"httpMethod": "POST",
"httpParams": {},
"httpHeaders": {},
"httpContentType": "text/html",
"properties": {
"userName": "xx",
"password": "xx"
},
"expiryError": "ExpiredAuthenticationToken",
"authError": [
"InvalidAuthenticationToken",
"AuthenticationFailed"
],
"timeOutError": "Read timed out",
"errorPath": "error.code",
"maxRefreshTryCount": 5,
"tokenResponsePath": "access_token",
"tokenType": "Basic",
"accessToken": "Basic xxx",
"username": "rvartak",
"password": "Pass@123",
"testConnectionParams": {
"http": {
"url": "http://xx.xx.xx.corp/SaviyntApp/PS/ExecutePSScript",
"httpMethod": "POST",
"requestBody": "",
"httpParams": {},
"httpHeaders": {
"contentType": "application/json",
"Authorization": "${accessToken}"
},
"httpContentType": "application/json"
},
"successResponse": [],
"successResponsePath": "responseText",
"errors": [
"fail",
"error",
"false"
],
"errorPath": "responseText"
}
}
}
}
in other json use
${connection.username}
${connection.password}
01/27/2024 12:27 PM
Thank you, @rushikeshvartak . I will test in the morning and keep u posted.
01/29/2024 08:23 AM
Hi @rushikeshvartak ,
After changing the connection param as you suggested,. No error is showing in the task, and the retries getting incremented. when I checked the logs it says access token is null.
here is the create account json
{
"accountIdPath": "accountName",
"responseColsToPropsMap": {},
"call": [
{
"name": "call1",
"connection": "acctAuth",
"url": "http://tmue1-savutil01.gaworkdaytest.local/SaviyntApp/PS/ExecutePSScript",
"httpMethod": "POST",
"httpParams": "{\"script\": \"\u0024name=\u0027jfoxx\u0027; \u0024cred = New-Object System.Management.Automation.PSCredential -argumentlist \u0027\u0024{connection.username}\u0027, (ConvertTo-SecureString \u0027\u0024{connection.password}\u0027 -AsPlainText -Force); \u0024onprem = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionURI http://tmue1-srv03.gaworkdaytest.local/PowerShell/ -Credential \u0024cred; Invoke-Command -Session \u0024onprem -scriptBlock {Enable-RemoteMailbox u002DIdentity \u0024using:name -RemoteRoutingAddress \u0024using:name\u0027@generalatlantictest.mail.onmicrosoft.com\u0027} \"}",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType": "application/json",
"successResponses": {
"response[9].Objectreturned": [
"Success"
]
},
"unsuccessResponses": {
"response[9].Objectreturned": [
"Failure"
]
}
}
]
}
and here is the connection json
{
"authentications": {
"userAuth": {
"authType": "Basic",
"url": "http://savutil01.gaworkdaytest.local/SaviyntApp/PS/ExecutePSScript",
"httpMethod": "POST",
"httpParams": {},
"httpHeaders": {},
"httpContentType": "text/html",
"properties": {
"userName": "<domain>\\svcSaviynt",
"password": "password"
},
"expiryError": "ExpiredAuthenticationToken",
"authError": [
"InvalidAuthenticationToken",
"AuthenticationFailed"
],
"timeOutError": "Read timed out",
"errorPath": "error.code",
"maxRefreshTryCount": 5,
"tokenResponsePath": "access_token",
"tokenType": "Basic",
"accessToken": "Basic <token>",
"username": "<domain>\\svcSaviynt",
"password": "password",
"testConnectionParams": {
"http": {
"url": "http://savutil01.gaworkdaytest.local/SaviyntApp/PS/ExecutePSScript",
"httpMethod": "POST",
"requestBody": "",
"httpParams": {},
"httpHeaders": {
"contentType": "application/json",
"Authorization": "${accessToken}"
},
"httpContentType": "application/json"
},
"successResponse": [],
"successResponsePath": "responseText",
"errors": [
"fail",
"error",
"false"
],
"errorPath": "responseText"
}
}
}
}
01/29/2024 12:44 PM
Does it works from postman
01/31/2024 07:36 AM
Hi @rushikeshvartak ,
Yes its working from Postman.
Hi Have configured the connection like -
{
"authentications":
{
"acctAuth":
{
"authType": "Basic",
"url": "http://savutil01.local/SaviyntApp/PS/ExecutePSScript",
"httpMethod": "POST",
"httpParams": {},
"httpHeaders": {},
"httpContentType": "application/json",
"expiryError": "Couldn't authenticate you",
"authError": [
"Couldn't authenticate you"
],
"timeOutError": "Read timed out",
"errorPath": "error",
"maxRefreshTryCount": 5,
"tokenResponsePath": "access_token",
"tokenType": "Basic",
"username": "domain\\\\username",
"password": "password",
"accessToken": "Basic token"
}
}
}
Now its throwing invalid username or password
I tried-
"username": "domain\\username",
"username": "domain\\\\username",
"username": "domain\username",
but not working. When I am putting the same in createaccountjson it works but throws some other issue.
Here is my create account json-
{
"accountIdPath": "accountName",
"responseColsToPropsMap": {},
"call": [
{
"name": "call1",
"connection": "acctAuth",
"url": "http://savutil01.local/SaviyntApp/PS/ExecutePSScript",
"httpMethod": "POST",
"httpParams": "{\"script\": \"\u0024name=\u0027jfoxx\u0027; \u0024cred = New-Object System.Management.Automation.PSCredential -argumentlist \u0027\u0024{connection.username}\u0027, (ConvertTo-SecureString \u0027\u0024{connection.password}\u0027 -AsPlainText -Force); \u0024onprem = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionURI http://srv03.local/PowerShell/ -Credential \u0024cred; Invoke-Command -Session \u0024onprem -scriptBlock {Enable-RemoteMailbox u002DIdentity \u0024using:name -RemoteRoutingAddress \u0024using:name\u0027@test.mail.onmicrosoft.com\u0027} \"}",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType": "application/json",
"successResponses": {
"response[9].Objectreturned": [
"Success"
]
},
"unsuccessResponses": {
"response[9].Objectreturned": [
"Failure"
]
}
}
]
}
01/31/2024 07:57 PM
01/27/2024 12:20 PM