- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2014 09:02 AM
I have a PowerShell MID Server Script file, Out-MyNameIs.ps1:
[CmdletBinding()]
Param(
[string]$name
)
Write-Output "%%MyNameIs%%"
Write-Output "$($name)"
Write-Output "%%"
I expect the Output of a Run PowerShell workflow activity to look like this:
%%MyNameIs%%
Chad
%%
In the activity, I have selected Out-MyNameIs.ps1 in the Script file field. Since my script requires the $name parameter, I have created a simple JSON string to put in the PowerShell script variables field:
{
"name" : "Chad"
}
I have replaced "name" with "$name" and "powershell_name"(based on comment in Run PowerShell activity definition), and have changed the $name parameter in the script to $powershell_param_name as it appears in the ecc queue:
<parameter name="powershell_param_name" value="Chad"/>
So far, all I have seen is:
%%MyNameIs%%
%%
Has anyone any experience with using PowerShell script variables that can help me get this working?
Thanks,
Chad
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2014 07:38 AM
Chad,
I found solution for this, it looks like below.
In your workflow you should pass name as :
"name": "${your variable here if dynamic}"
and in powershell
$localVar = $env:SNC_name; // this is your workflow var
Thanks,
Kartheek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2014 01:31 AM
Chad,
Did you get solution for it? I am having issues in passing variables to powershell script, I am passing like $env:SNC_<variable_name> but script is failing but if i hard code value there its success.
Thanks,
Kartheek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2014 07:07 AM
Kartheek,
I have not managed a solution for using the PowerShell script variables field yet. Are you using the Script file field on the Run PowerShell activity to pass your script or are you using the command window? I have done alot of PowerShell activities so maybe I could help get yours going.
Regards,
Chad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2014 07:38 AM
Chad,
I found solution for this, it looks like below.
In your workflow you should pass name as :
"name": "${your variable here if dynamic}"
and in powershell
$localVar = $env:SNC_name; // this is your workflow var
Thanks,
Kartheek
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2014 07:53 AM
Kartheek,
That did it! Thank you very much.
Regards,
Chad