Instatiate a Probe via Script (Business Rule)

mahmoudhabiball
Giga Contributor

Hi,

I am new to ServiceNow and I could find no right solution for my Problem (Out of the box)

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.

Is there any way to do it?

1 ACCEPTED SOLUTION

mahmoudhabiball
Giga Contributor

So,


there is no out of the box solution for this. An update set like the one described here by John j. Andersen needs to be loaded: http://www.john-james-andersen.com/blog/service-now/powershell-probe-and-utility-for-servicenow.html


View solution in original post

12 REPLIES 12

Hello Mahmoud,



can you add the below line and try once and check logs.



var psResponse = psProbe.execute(true);


gs.log("Executed Powershell Probe");



Thanks,


Jag.



Please mark correct/helpful as needed.


Hello,



the line is not being hit.


However I can see he following log record:


org.mozilla.javascript.EcmaError: "PowershellProbe" is not defined.
    Caused by error in sys_script.84088429f884d700a4debe38ef5cb787.script at line 6


          3:  


          4:   gs.log("Executed Powershell Probe 1");


          5:


==>     6:   var psProbe= new PowershellProbe( "mid.server.midserver_scom", '127.0.0.1');


          7:   gs.log("Executed Powershell Probe 2");


          8:


          9:   var psResponse = psProbe.execute(true);

Hello Mahmoud,



I guess mid.server.midserver_scom is a property in your system.   If it is a property. can you try like below.




(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);



Thanks,


Jag.



Please mark correct/helpful as needed.





Hi,



Still the same Problem:



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);


Hi Mahmoud,



Can you let me know if you have written any scripts on table "ecc_agent_script_file"



Thanks


Jag.



Please mark correct/helpful as needed.