ServiceNow Orchestration - MID Server selection with PowerShell activities
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2018 07:54 AM
I have a PowerShell activity that needs to run on a specific MID Server that is not the default MID server, but the MID server is being randomly selected. Sometimes when I run "Test Inputs", it returns the output successfully and sometimes I get "authentication failed for user". When I get the "authentication failed" message, I can see messages from the activity in the default MID Server's agent.log that it tried to run there. Here is what I have read and configured so far:
I have read this post already: Powershell Orchestration Tips & Tricks .
I have the desired MID server configured with Supported Application -> All (this is for Orchestration), an IP range set (x.x.x.x/23) with type include, and capabilities ALL, PowerShell, and ResolveDNS.
I have the default MID server configured with Supported Application -> ALL, IP Ranges -> ALL, and capabilities ALL and PowerShell.
I also have an entry in the cmdb_ip_address_dns_name that translates the target host name in the PowerShell activity from name to IP address. I have tried using both name and IP on the target host field in the PowerShell activity with similar results. The IP address of the target host is in the IP range defined on the desired MID Server configuration.
Do I need to define an exclude for the default MID server so that it doesn't try to go there? How do I configure "everything goes to the default MID server unless the target host is in this IP range?"
Any advice is appreciated. Thank you!
- Labels:
-
Orchestration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2018 12:47 PM
What I've done with multiple PowerShell activities is create a javascript activity prior to power shell calls with the following
var midServerObj = new GlideRecord('ecc_agent');
midServerObj.addQuery('name', 'MIDsrvr');/set your midserver name here,
// or add another query line for capabilities
midServerObj.query();
while (midServerObj.next()) {
// add code here to process the incident record
workflow.scratchpad.midServer = midServerObj.host_name;
if (workflow.scratchpad.isDebug){
workflow.info(' *workflow.scratchpad.midServer: ' + workflow.scratchpad.midServer);
workflow.info(' *midServerObj.host_name: ' + midServerObj.host_name);
}
}
Then in my power shell activities (custom and standard) I assign the midserver with ${workflow.scratchpad.midServer}
I'm using this for AD and Office 365 management, as well as custom powershell calls to internal web services in my network for gmail management.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2018 06:13 AM
Where in your PowerShell activity are you assigning the MID server? In the target host field? The article I linked above states that the MID server and target host shouldn't be the same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2018 10:24 AM
In my case, I'm usi g the target as the midserver. for what i have built out, I'm building the credentials in the powershell script itself so that when the script is executed, it's not using the midserver credentials. also, I'm using my midserver as a gateway for AD and Ofice365, so I have the required powershell add-on modules installed there.
Most likely, not best practice, but currently I'm only using the powershell activities for AD, google and Office365 administration for the onboarding process I built for our users.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2018 04:29 AM