04-24-2013 12:03 PM
I need to pass one argument to my powershell script in Tidal Orchestrator. c:\script.ps1 "argument". Argument is hidden string
How should I enter an argument in the "Script Arguments" field?
I tried a lot of combinations but nothing works. Tidal activity doesn't pass argument to powershell script at all.
It only works if I pass it in "Script to execute on target" field. But it's not what I want. I can not pass hidden string in this field.
Any suggestions are welcome.
Solved! Go to Solution.
04-24-2013 12:51 PM
The issue may be with the use of double quotes around the parameter, which you would understandably want for a password.
Have a look at the TAP here:
https://supportforums.cisco.com/docs/DOC-27545
It doesn't pass a parameter in Invoke-Expression, but you can.
Change the Execute Windows PowerShell Script activity to have two parameters, one that is the scriptname and one that is the securestring. The script should look like this:
Param(
[String]$SecureString
)
Invoke-Expression "C:\script.ps1 `'$SecureString`'"
#End of code snippet
The $SecureString can be passed in using the "Script Arguments" field as Christopher (aka Shaun) showed.
The issue with quotes is handled by escaping the quotation marks around the secure string. That's
Double-Quote ScriptName Backtick Single-Quote $SecureString Back-Tick Single-Quote Double-Quote
04-24-2013 12:11 PM
Script to execute on target is the powershell script itself. Why is this not valid for you? What is the requirement to call the script and not have the script in the script box?
If you put something in the script arguments box (using your hidden string). You should be able to reference the arguments array.
ie. $args[X]
Here is a sample of some timezone code I wrote today with 7 arguments passed in...
$date1 = New-Object System.DateTime $args[2], $args[0], $args[1], $args[3], $args[4], 0
$TZ1 = $args[5]
$DTFormat = $args[6]
$tz = [System.TimeZoneInfo]::FindSystemTimeZoneById("$TZ1");
$output=[System.TimeZoneInfo]::ConvertTimeToUtc($date1, $tz)
$outputAdd = $output.AddSeconds($args[7])
$out = $outputAdd.ToString("$DTFormat")
echo $out
I realize I wrote mine in there directly and did not export it to a separate PS1 file, but there was no need.
Can you do...
script.ps1 $args[0]
in your script field? And then make the argument a hidden string in the script arguments box?
It that does not work for you, you might investigate calling powershell directly through the windows execute activity, but I think it should work via powershell activity.
If nothing ends up working, I would suggest opening a case with TAC to capture the use-case for engineering.
04-24-2013 12:51 PM
The issue may be with the use of double quotes around the parameter, which you would understandably want for a password.
Have a look at the TAP here:
https://supportforums.cisco.com/docs/DOC-27545
It doesn't pass a parameter in Invoke-Expression, but you can.
Change the Execute Windows PowerShell Script activity to have two parameters, one that is the scriptname and one that is the securestring. The script should look like this:
Param(
[String]$SecureString
)
Invoke-Expression "C:\script.ps1 `'$SecureString`'"
#End of code snippet
The $SecureString can be passed in using the "Script Arguments" field as Christopher (aka Shaun) showed.
The issue with quotes is handled by escaping the quotation marks around the secure string. That's
Double-Quote ScriptName Backtick Single-Quote $SecureString Back-Tick Single-Quote Double-Quote
04-24-2013 10:35 PM
Thank everybody for your answers. I pasted content of the script in "Script to execute on target" field and it works now. It didn't work because I used windows path to PS1 file in this field.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide