and more in a single search tool across platforms. Read the announcement here. |
02/29/2024 09:27 AM
Trying to pass the following attributes in a PS script but Saviynt WinPS connector is treating them as plain text:
Please advise on how these variables can be passed in the WinPS create acct script.
Thank you
03/01/2024 06:24 AM
Hi @Kshah
Please refer to the below posts which may be helpful.
WINPS Connector: Error in CreateAccount task - Saviynt Forums - 24606
Also please try the format similar to the below and see if it works.
Best Practices for Configuring PowerShell Scripts (saviyntcloud.com)
{
"CREATEACC":[
"script=\$pw = convertto-securestring '${PSSCRIPT_PASSWORD}' -asplaintext -force;\$mycred = new-object -typename System.Management.Automation.PSCredential -argumentlist 'domainname1\\\\Administrator',\$pw;Invoke-Command -ComputerName 'localhost' -Credential \$mycred -ScriptBlock {C:/Scripts/CreateADUser.ps1 \"${user.username}\" \"${user.firstname}\" \"${user.lastname}\"}"
],
"SuccessResponses":{
"OBJECTTOREAD":"get(0).PSShowComputerName",
"SUCCESSVALUE":"True"
}
}
Regards,
Dhruv Sharma
03/01/2024 08:44 AM
We tested with \"${user.username}\" and the same issue occurred. Attribute gets passed as "${user.username}"
Please advise
03/02/2024 01:09 PM
Use escape character for password
03/04/2024 02:43 PM
We are trying escape password. Single / escape does not work and throws error. double // escape gives same issue. Variable is passed as plain text
03/04/2024 02:45 PM
For reference here is what we tried:
03/05/2024 01:01 AM
Hi @Kshah
Thanks for the update. We are checking this internally and will keep you posted.
Regards,
Dhruv Sharma
03/05/2024 08:34 PM
Hi @Kshah
Please use the below format and let us know if it works.
{
"CREATEACC": [
"Script=add-pssnapin Microsoft.exchange.management.powershell.e2010; $password=ConvertTo-SecureString 'XXXXXX' -AsPlainText -Force; $onpremcred=New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList 'XXXX',$password; $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri XXXXXX.net/PowerShell/ -Credential $onpremcred; New-Mailbox -LinkedDomainController 'XXXXXXXX' -Name '\${user.firstName} \${user.lastName} \${task.accountName}' -DisplayName '\${user.firstName} \${user.lastName}' -OrganizationalUnit 'OU=XXXXXXXX' -Alias 'LinkedAccount' -LinkedMasterAccount 'Domain\\\${task.accountName}' -UserPrincipalName '\${task.accountName}@XXXXX.com' -Database 'XXXXXX' -DomainController 'XXXXXXXX.net'"
],
"SuccessResponses": [
"Objectreturned",
"List",
"Success",
"TRUE",
"True",
"SUCCESS"
]
}
Regards,
Dhruv Sharma
03/10/2024 11:11 PM - edited 03/10/2024 11:12 PM
Here is the working JSON
{
"CREATEACC": [ "Script=\$start = add-pssnapin Microsoft.exchange.management.powershell.e2010; \$password = ‘XXXXXXXX’| ConvertTo-SecureString -AsPlainText -Force; \$psCred = New-Object System.Management.Automation.PSCredential -ArgumentList ('svcSaviynt’, \$password); \$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri 'http://exchange01.company-domaincorp.net/PowerShell/' -Authentication Kerberos -Credential \$psCred; New-Mailbox -LinkedDomainController 'k01t.company-domainstores.test' -Name '${user.firstname} ${user.lastname} ${user.username}' -DisplayName '${user.lastname} ${user.firstname}' -OrganizationalUnit 'OU=PStores Mailbox Users,OU=Users,OU=company-domain,DC=company-domaincorp,DC=net' -Alias '${user.firstname}.${user.lastname}' -LinkedMasterAccount 'teststores\\\\${user.username}' -UserPrincipalName '${user.username}@company-domaincorp.com' -Database 'Database01' -DomainController 'k01.company-domaincorp.net'"
],
"SuccessResponses": [
"Objectreturned",
"List",
"Success",
"TRUE",
"True",
"SUCCESS"
]
}