- 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-18-2020 06:35 AM
you can add like $appid = "$appid"
on mid server script instead of app_id=2265551 use app_id=$appid
on your powershell activity use something like below in Powershell script variable section
{
"appid" : "2265551"
}
if it's variable or field than you can do
{
"appid" : "${current.variables.XXXX}"
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2020 06:55 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2020 07:34 AM
How are you kicking this off? from workflow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2020 06:53 AM
Hi Mike,
No,I used scheduled job to kicking the output queue.
Thanks,
Uma.