- 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 10:07 AM
Hi Mike,
<?xml version="1.0" encoding="UTF-8"?>
<parameters>
<parameter name="skip_sensor" value="true"/>
<parameter name="probe_name" value="Windows - Powershell"/>
<parameter name="MIDScriptFile" value="scripts\PowerShell\Test_Veracode.ps1"/>
<parameter name="appid" value="226551"/>
</parameters>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2020 06:58 AM
Hi,
Following link will help:
https://hi.service-now.com/kb_view.do?sysparm_article=KB0547043
Thanks
Sudhanshu

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2020 08:04 AM
I thought the standard way was to set "Topic" to "Command" and to set "Name" to "powershell <arguments>" or to set "Payload" to script location
e.g.

- 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 10:53 AM
Hi Mike,
Thank you so much for the support.
It's working.Thank you!!!
Thanks,
Uma.