- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2018 03:00 AM
Hi,
I'm trying to automate as much as possible the deployment of MID servers to many branch environments. I have figured out how to get the MID server to deploy as a Windows service without requiring end user UI by preconfiguring the config files, but I end up with a new MID server entry in the instance that needs to be manually validated before it will work. Since these new MID servers could be deployed at all hours by a deployment script, I need the validation to happen automatically.
I can't find any mention of how to do this in the API reference. Is this something I'm missing or is there no way to automate this at all and it HAS to be done manually?
Thanks,
Mark.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2018 09:18 PM
Hi Mark,
To follow-up on what Arnoud wrote. I took a look at the MIDServerAjax script include that is called to validate a Mid Server from the UI.
If you add the code below to a scheduled job and set the job to run on a schedule of your choosing, you can make sure that any unvalidated Mid Servers get validated.
var mm = new MIDServerManage();
var gr = new GlideRecord("ecc_agent");
//search for mid servers that aren't validated
gr.addQuery("validated", false);
gr.query();
while(gr.next()){
mm.validate(gr.name);
}
Hope this helps.
Let me know if you have any questions.
Thanks,
Cody
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2018 02:20 AM
Script Include MIDServerManage has a method validate()
it is not documented on docs, normally its called from the Validate UI Action via a GlideAjax call in ScriptInclude MIDServerAjax
Did not test, but this should work.
(new MIDServerManage()).validate("your_midserver_name");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2018 03:29 AM
Thanks Arnoud, it's great to know there is a way to do this.
I'm afraid I'm very new to ServiceNOW and I'm scripting my automation in PowerShell. I'm fairly sure I know how to drive the REST API that way, but I have no idea how to drive the javascript stuff server side. I'm guessing there'll be a .js library exposed somewhere, but I'm a little lost in the documentation and can't find out what he URI for that is.
Any help gratefully received.
Thanks,
Mark.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2018 04:29 AM
Will this always be the same pre configured instance?
In theory then you could do it via a Scripted Rest API.
But probably it is a conscious decision not to enable this, to ensure you dont have unwanted mid server connected to your instance, so I would not recommend this.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2018 09:18 PM
Hi Mark,
To follow-up on what Arnoud wrote. I took a look at the MIDServerAjax script include that is called to validate a Mid Server from the UI.
If you add the code below to a scheduled job and set the job to run on a schedule of your choosing, you can make sure that any unvalidated Mid Servers get validated.
var mm = new MIDServerManage();
var gr = new GlideRecord("ecc_agent");
//search for mid servers that aren't validated
gr.addQuery("validated", false);
gr.query();
while(gr.next()){
mm.validate(gr.name);
}
Hope this helps.
Let me know if you have any questions.
Thanks,
Cody