0

I have defined a PowershellProbe with a script which recieves a Parameter (powershell_param_someparam). Running the Script from on the GUI works successfully, yet I have no idea how would I be able to Access and Trigger this Pobe from a bussiness rule or another script type running on a Jakarta Instance.

Instantiating it from a script throws an exception like this one:

com.glide.script.RhinoEcmaError: "PowershellProbe" is not defined.
sys_script.84088429f884d700a4debe38ef5cb787.script : Line(7) column(0) 5: 
6: var midServer = gs.getProperty("mid.server.connector_default");
==>   7:  var psProbe= new PowershellProbe(midServer, '127.0.0.1');
8:  gs.log("Executed Powershell Probe 2");
9: 10:  var psResponse = psProbe.execute(true);

The Original Code looks like this:

(function executeRule(current, previous /*null when async*/) {
var midServer = gs.getProperty('mid.server.midserver_scom');
var psProbe= new PowershellProbe( midServer, '127.0.0.1');
var psResponse = psProbe.execute(true);
gs.log("Executed Powershell Probe");
})(current, previous);

Am I doing it wrong?

mh133
  • 135
  • 12

1 Answers1

2

Your error says: "PowershellProbe" is not defined.. If you say it works from GUI I assume you have it installed. Then the issue might be with application scope. Please make sure you are calling the script from application scope "global". If you wish to call the script from different application scope use namespace like this:

var powerProbe = new global.PowershellProbe(mid, server);

Another thing is that you never set PowerShell code that is supposed to be executed. You can do this by defining mid server script and passing it with setMidScript or you can set it with setScript like in example below:

var mid = 'yourMIDServer';
var server = '127.0.0.1';
var powerShellCode = 'Get-ChildItem';

var powerProbe = new PowershellProbe(mid, server);
powerProbe.setScript(powerShellCode);
var response = powerProbe.execute(true);

gs.log(JSON.stringify(response));
BartDoe
  • 146
  • 5