Advanced Discovery Troubleshooting - WMI

doug_schulze
ServiceNow Employee
ServiceNow Employee

My friend in the BRK showed me this handy little way to help prove a WMI connection outside the midserver but using the same components asking the question. This can come in handy when you can't figure out why you are having problems connecting to a Windows OS and want to see the raw return before the "machine" starts processing it.

*As always be careful whenever stepping outside the controls of the UI, this process will have no more impact then a regular discovery but you want to be sure you have the necessary understanding of how scripting works, do this with an idle mid server application and the ability to understand the returns...have fun, this can be very helpful to prove where the problem lies...

1. RDP to Midserver host as the Midservers 'runs as' user
2. Open a command prompt and navigate to your midserver /agent folder
3. Create a script (test.js) with the necessary query you are trying to re-create, below is an example of a single command trying to pull back an Operating System value


var scanner = getScanner();
if (scanner) {
scanner.addFetch('Win32_OperatingSystem.Caption');
scanner.fetch();
}


4. After you save it, type and execute the line below

cscript lib\WMIRunner.js [IP of the target] test.js

5. Review results


Again, this can help with troubleshooting connecting to a machine for the first time or fixing a troublesome probe...Knowledge is power... enjoy

20 REPLIES 20

dmfranko
Kilo Guru

Got anything similar for Powershell/WinRM ?   Also, seems that WMIRunner.js moved from lib to scripts just in case anyone goes looking for it.