- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2020 06:26 AM
Hi Team,
I want to pass parameters into mid-server power shell script files.Can anyone help me how we can pass.
In below script i need to pass app_id value for the url.
Thanks,
Uma.
Solved! Go to Solution.
- Labels:
-
Instance Configuration

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2020 10:32 AM
I think this is final. I tested it and works for me.
Scheduled Job
var ecc = new GlideRecord("ecc_queue");
ecc.initialize();
ecc.agent = "mid.server.XXXX";
ecc.topic = "Powershell";
ecc.name = "Windows - Powershell";
ecc.source = "10.XXXX";
ecc.queue = "output";
ecc.state = "ready";
ecc.payload = this._getPayloadString();
ecc.insert();
function _getPayloadString() {
var xmldoc = new XMLDocument("<parameters/>");
var el = xmldoc.createElement("parameter");
xmldoc.setCurrent(el);
xmldoc.setAttribute("name", "skip_sensor");
xmldoc.setAttribute("value", "true");
xmldoc.setCurrent(xmldoc.getDocumentElement());
el = xmldoc.createElement("parameter");
xmldoc.setCurrent(el);
xmldoc.setAttribute("name", "probe_name");
xmldoc.setAttribute("value", "Windows - Powershell");
xmldoc.setCurrent(xmldoc.getDocumentElement());
el = xmldoc.createElement("parameter");
xmldoc.setCurrent(el);
xmldoc.setAttribute("name", "MIDScriptFile");
xmldoc.setAttribute("value", _getScriptFilePath('e517b060db36d010d97f50aadc96191a'));
xmldoc.setCurrent(xmldoc.getDocumentElement());
el = xmldoc.createElement("parameter");
xmldoc.setCurrent(el);
xmldoc.setAttribute("name", "powershell_param_appid");
xmldoc.setAttribute("value", '10555');
return xmldoc.toString();
}
function _getScriptFilePath(file_id) {
var scriptPath = '';
var gr = new GlideRecord('ecc_agent_script_file');
if (gr.get(file_id)) {
var path = '';
while (!gs.nil(gr)) {
path = gs.nil(path) ? gr.name : gr.name + '\\' + path;
gr = gr.parent;
}
scriptPath = 'scripts\\' + path;
}
return scriptPath;
}
$requestVersion = "vcode_request_version_1"
$method = 'GET'
$id = "$appid"
$urlBase = "xxx.xxxx.com"
$urlPath = "/api/5.0/getappinfo.do?app_id=$id"
$url="https://xxx.xxx.com/api/5.0/getappinfo.do?app_id=$id"

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2020 07:01 AM
Can you share that script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2020 07:12 AM
Hi Mark,
Please find below script
var ecc = new GlideRecord("ecc_queue");
ecc.initialize();
ecc.agent = "mid.server.xxxx";
ecc.topic = "Powershell";
ecc.name = "Windows - Powershell";
ecc.source = "10.xxxxxx6";
ecc.queue = "output";
ecc.state = "ready";
ecc.payload = this._getPayloadString();
ecc.insert();
function _getPayloadString() {
var xmldoc = new XMLDocument("<parameters/>");
var el = xmldoc.createElement("parameter");
xmldoc.setCurrent(el);
xmldoc.setAttribute("name", "skip_sensor");
xmldoc.setAttribute("value", "true");
xmldoc.setCurrent(xmldoc.getDocumentElement());
el = xmldoc.createElement("parameter");
xmldoc.setCurrent(el);
xmldoc.setAttribute("name", "probe_name");
xmldoc.setAttribute("value", "Windows - Powershell");
xmldoc.setCurrent(xmldoc.getDocumentElement());
el = xmldoc.createElement("parameter");
xmldoc.setCurrent(el);
xmldoc.setAttribute("name", "MIDScriptFile");
xmldoc.setAttribute("value",_getScriptFilePath('e9c7b33c1b081010f713ed7b2f4bcbcc') );
return xmldoc.toString();
}
function _getScriptFilePath(file_id) {
var scriptPath = '';
var gr = new GlideRecord('ecc_agent_script_file');
if (gr.get(file_id)) {
var path = '';
while (!gs.nil(gr)) {
path = gs.nil(path) ? gr.name : gr.name + '\\' + path;
gr = gr.parent;
}
scriptPath = 'scripts\\' + path;
}
return scriptPath;
}
Thanks,
Uma.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2020 07:18 AM
try below
var ecc = new GlideRecord("ecc_queue");
ecc.initialize();
ecc.agent = "mid.server.xxxx";
ecc.topic = "Powershell";
ecc.name = "Windows - Powershell";
ecc.source = "10.xxxxxx6";
ecc.queue = "output";
ecc.state = "ready";
ecc.payload = this._getPayloadString();
ecc.insert();
function _getPayloadString() {
var xmldoc = new XMLDocument("<parameters/>");
var el = xmldoc.createElement("parameter");
xmldoc.setCurrent(el);
xmldoc.setAttribute("name", "skip_sensor");
xmldoc.setAttribute("value", "true");
xmldoc.setCurrent(xmldoc.getDocumentElement());
el = xmldoc.createElement("parameter");
xmldoc.setCurrent(el);
xmldoc.setAttribute("name", "probe_name");
xmldoc.setAttribute("value", "Windows - Powershell");
xmldoc.setCurrent(xmldoc.getDocumentElement());
el = xmldoc.createElement("parameter");
xmldoc.setCurrent(el);
xmldoc.setAttribute("name", "MIDScriptFile");
xmldoc.setAttribute("value", _getScriptFilePath('e9c7b33c1b081010f713ed7b2f4bcbcc'));
xmldoc.setCurrent(xmldoc.getDocumentElement());
el = xmldoc.createElement("parameter");
xmldoc.setCurrent(el);
xmldoc.setAttribute("name", "appid");
xmldoc.setAttribute("value", '10555');
return xmldoc.toString();
}
function _getScriptFilePath(file_id) {
var scriptPath = '';
var gr = new GlideRecord('ecc_agent_script_file');
if (gr.get(file_id)) {
var path = '';
while (!gs.nil(gr)) {
path = gs.nil(path) ? gr.name : gr.name + '\\' + path;
gr = gr.parent;
}
scriptPath = 'scripts\\' + path;
}
return scriptPath;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2020 07:32 AM
Hi Mike,
Could you please tell me the place in mid server script file and schedule job in both i need to change the script right?
Thanks,
Uma.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2020 07:37 AM
Yes, if you share mid server script than I can update it for you. But you can add
$appid = "$appid"
right before
$url=