Custom probe/sensor Local Admins on a computer

doug_schulze
ServiceNow Employee
ServiceNow Employee

Created a new probe/sensor (available here) to fill the afternoon that pulls back the local administrators configured on a host.   You will need to create a new table and in that table a reference field back to computer.   As you can see in the sensor I created a table (not extended from anything called Local Administrators and a reference field to cmdb_ci_computer called Configured on.   Props to Ryan Zulli for his all star assist

//Note that you should have custom tables that you are inserting the records into and syncing on

  this.addToRelatedList('u_local_administrators', adminList, 'u_configured_on', 'name');

Also in the probe you'll see the command that is being run 'net localgroup administrators' well you can easily change that to pull in 'net localgroup "remote desktop users"'

Hope someone can get some good use from it!

And as always, remember sharing is caring..

7 REPLIES 7

A Westervelt
Mega Guru

Doug, it's almost as if you were reading my mind.


csargent
Kilo Explorer

Doug, I should have reviewed the .xml a bit closer and would have seen it was an update set.   Probe, probe parameter and sensor created.   I created the table u_local_administrators with a reference field to cmdb_ci_computer called Configured on .   I tested the probe and it is not populating that table.  



What am I missing?



//Note that you should have custom tables that you are inserting the records into and syncing on


  this.addToRelatedList('u_local_administrators', adminList, 'u_configured_on', 'name');



I understand this.addToRelatedList is 'tablename', array name, 'reference name' and key name.   I added 'name' as the reference key to configured_on.   Was that correct?


I actually forgot to test this out as the functionality was what I was looking for. There's a couple lines wrong in the script on the lines below.



18. adminInfoArray.u_name = lines[i].trim();


28. this.addToRelatedList('u_local_administrators', adminList, 'u_configured_on', 'u_name');



adminInfoArray.u_user and addToRelatedList(blah,blah,blah,name) need to be synced to the same field value. Since SN loves to prefix everything with "u_", u_name fits just perfectly.


Candy,



Double check that you have added the probe to your classifier for the system you are testing (it gets me all the time)