- 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-22-2016 03:55 AM
Hi chadlockwood,
In Service Now-->Mid Server--> Script Files can we write a power shell script to start a Run book on System Center Orchestrator and get response ?
Regards,
Vinay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2016 10:24 AM
Vinay,
I don't have any experience with System Center Orchestrator, however, I have not yet found a PowerShell script that I could not run through ServiceNow. I'm guessing that you would need to have the SCO module installed on your MID server, or otherwise be able to create an implicit remote connection to your SCO server then you could import any necessary SCO cmdlets into your MID server script file. Basically, if there is already a PowerShell cmdlet, or you can write PowerShell to accomplish it, you can do it from inside ServiceNow.
On a side note, are you going to be at Knowledge 16 and if so, would you be interested in getting ServiceNow administrators who use PowerShell together to share info and discuss pitfalls/successes? I feel like we need a subculture to emerge at Knowledge.
Regards,
Chad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2016 07:04 PM
Hi Chad,
Thanks for your response.
Well I am not attending the Knowledge 16, to attend need to cross overseas.
Surely will be part of Administrator sub group. I support.
Regards,
Vinay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2016 07:47 PM
Hi Chad,
We need to start a job on Web Service REST END Point of System Center Orchestrator from service now.
got the code as below. Can we use the same in script files of mid server and get response any IDEA ?
POST http://SERVER:81/Orchestrator2012/Orchestrator.svc/Jobs HTTP/1.1
User-Agent: PowerShell API Client (PowerShell 2.0; .NET CLR 2.0.50727.5448; WinNT 6.1.7601 Service Pack 1)
Accept: application/atom+xml,application/xml
Content-Type: application/atom+xml
Accept-Encoding: identity
Accept-Language: en-US
DataServiceVersion: 1.0;NetFx
MaxDataServiceVersion: 2.0;NetFx
Pragma: no-cache
Host: SERVER:81
Content-Length: 779
Expect: 100-continue
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<entry xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"
xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"
xmlns="http://www.w3.org/2005/Atom">
<content type="application/xml">
<m:properties>
<d:RunbookId m:type="Edm.Guid">0336c79b-ca82-449e-ad55-aefa9fb47fad</d:RunbookId>
<d:Parameters><Data><Parameter><ID>{60a8fa04-6293-4767-b842-46cba5790553}</ID><Value>Hello</Value></Parameter><Parameter><ID>{c24d1cc5-deba-4bb5-b02e-44caf0fb296c}</ID><Value>World</Value></Parameter></Data></d:Parameters>
</m:properties>
</content>
</entry>
Regards,
Vinay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2016 07:51 PM