Dear Matthias,
Thanks for your reply.
Please find the below job script which i have written.
Windows Job :
:SET &LOGIN# = GET_LOGIN("LOGIN_TEST","*","win",PASSWORD)
:print This is : &LOGIN#
: SET &SecurePassword# = (&UC_JOBMD CMD="echo &LOGIN#")
:print This is : &SecurePassword#
:SET &URL# = "somepath"
&UC_JOBMD CMD="echo &LOGIN#" > temp.txt
set /p PASS=<temp.txt
powershell -command D:\test\pstest\testing.ps1 -username "<ara_clnt>/<username>/<department>" -password %PASS% -artifacturl &URL# -profile "someprofile"
@set retcode=%errorlevel%
@if NOT %ERRORLEVEL% == 0 goto :retcode
Powershell Script:
Param(
[string]$ara_uri = "<ARA_login_page>",
[string]$username = "",
[SecureString]$password = "",
[string]$artifacturl,
[string]$profile
)
$body = @"
{
"workflow": "<ARA_Workflow>",
"overrides": {
"workflow": {
"/artifactory/full-url": "$artifacturl",
"/deployment/profile": "$profile"
}
}
}
"@;
$pw = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($password))
$params = @{uri = $ara_uri;
Method = "POST";
Body = $body;
ContentType = "application/json";
Headers = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$($username):$($pw)"));
}
}
invoke-webrequest @params
Below is the job report with error message:
C:\>C:\Automic\Agents\Windows\bin\UCXJWX6M.EXE CMD="echo 0000000000020482" 1>temp.txt C:\>set /p PASS= 0<temp.txt C:\>powershell -command D:\test\pstest\testing.ps1
-username "<ara_clnt>/<username>/<department>"
-password 0000000000020482 -artifacturl &URL# -profile "someprofile"D:\test\pstest\testing.ps1
: Cannot process argument transformation on
parameter 'password'. Cannot convert the "20482" value of type "System.Int32" to type "System.Security.SecureString". At line:1 char:72 + D:\test\pstest\testing.ps1
-username <ara_clnt>/<username>/<department> -password 000000000 ... + ~~~~~~~~~ + CategoryInfo : InvalidData: (:) [testing.ps1
], ParameterB indingArgumentTransformationException + FullyQualifiedErrorId : ParameterArgumentTransformationError,testing.ps1