- 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
01-25-2016 07:04 AM
Vinay,
From the link you sent it looks like the author has created a PowerShell module that you could download and install on your MID server. Then you could create a MID server script file using those cmdlets. However, since you already have a web service call, I would try using the REST message activity in a ServiceNow workflow, if that is what you are looking to do.
Regards,
Chad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2016 06:28 AM
Chad,
Yes, now I am using REST Message POST function to start the run book and pass the values on to REST END point of SCORCH.
getting below error
{
"error": {
"code": "", "message": {
"lang": "en-US", "value": "Error reading syndication item: 'Data at the root level is invalid. Line 1, position 1.'."
}
}
}
Regards,
Vinay M
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2016 08:11 AM
Vinay,
I'm sorry but that just passed my skill level. If you want to try PowerShell, I would suggest you login to you MID server, if possible, write a PowerShell script there that does what you want, then transfer that to a MID server script file. At that point you would just have to pass the appropriate parameters into a Run PowerShell activity in your workflow.
Regards,
Chad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2015 11:57 AM
Thank you Chad! You have no idea how much you helped.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2015 01:00 PM
Dion,
Glad this helped you. My experience with PowerShell in ServiceNow has been rocky but for the help of a few knowledgable individuals that got there before me. If there is anything else you need help with don't hesitate. Maybe we could build up a PowerShell subcommunity before K16. Who's with me?
Chad