Click here to Skip to main content
15,881,823 members
Articles / Programming Languages / XML

WMI Hardware/Software Enumeration Script

Rate me:
Please Sign up or sign in to vote.
4.78/5 (24 votes)
29 Apr 2009CPOL14 min read 263.1K   5.6K   91  
This article presents a JScript/WMI/WSH script - the core of any inventory management application.
1. Running 

   [cscript] wmiadmin.js

(without parameters) collects info about local computer and opens the resulting xml file in a browser.

2. Running

   [cscript] wmiadmin.js xxx.xxx.xxx.xxx

collects info about computer who's IP address is 'xxx.xxx.xxx.xxx' and opens the resulting xml file in a browser.

3. Given the 'silent' key, script runs in a 'silent mode':

   [cscript] wmiadmin.js /silent xxx.xxx.xxx.xxx

collects info about computer who's IP address is 'xxx.xxx.xxx.xxx' and doesn't show the resulting xml file;

   [cscript] wmiadmin.js /silent

collects info about local computer and doesn't show the resulting xml file.

4. You can specify as much IP adresses as you wish:

   [cscript] wmiadmin.js /silent xxx.xxx.xxx.xxx yyy.yyy.yyy.yyy zzz.zzz.zzz.zzz

Note: for all of the above methods, target computer's OS must contain a user account
      with username/password that match user's credentials that local system provides.

5. Given the 'username' and 'password' keys, script uses given credentials instead of
   those provided by the system:

   [cscript] wmiadmin.js /username:alice /password:anywordyoulike xxx.xxx.xxx.xxx

6. Given the 'domain' key, you can query a computer in a different domain; NTLM authentication is used.

   [cscript] wmiadmin.js /domain:acme /username:alice /password:anywordyoulike xxx.xxx.xxx.xxx

7. Given the 'auth' key, you can control the way you authenticate on the target domain.
   If this key is equal to "kerberos", Kerberos authentication is used; otherwise, NTLM
   authentication is used.

   [cscript] wmiadmin.js /domain:acme /username:alice /password:anywordyoulike /auth:kerberos xxx.xxx.xxx.xxx

8. Provided 'wmi_administrator.htm' page is a prototype of an WMI administration tool.
   You can specify target computer's IP address, username, password and domain name
   in the appropriate fields; hit "Start WMI query" to retrieve the WMI info.

Note: before running the GUI tool, please check your browser security settings to be sure
      that it allows creation and execution of ActiveX components.

-------------------------------------------------------------------------------

Requirements: - WMI installed on every computer you query;
              - WSH installed on computer on which the script is run;
              - 'wmiadmin.xsl' stylesheet must reside in the directory
                            where the 'wmiadmin.js' script is located.

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Freelance software engineer
Russian Federation Russian Federation
Dmitry Khudorozhkov began programming (and gaming) with his ZX Spectrum in 1989. Having seen and used all IBM PCs from early XT to the latest x64 machines, now Dmitry is a freelance programmer, living in Moscow, Russia. He is a graduate of the Moscow State Institute of Electronics and Mathematics (Applied Mathematics).

He is proficient in:

- C/C++ - more that 9 years of experience. Pure Win32 API/MFC desktop programming, networking (BSD/Win sockets), databases (primarily SQLite), OpenGL;

- JavaScript - more that 6 years of experience. Client-side components, AJAX, jQuery installation and customization;

- Firefox extensions (immediatelly ready for addons.mozilla.org reviewing) and Greasemonkey scripts. As an example of extensions Dmitry made you can search for FoxyPrices or WhatBird Winged Toolbar;

- XML and it's applications (last 2 years): XSLT (+ XPath), XSD, SVG, VML;

- ASP.NET/C# (webservices mostly);

Also familiar with (= entry level):

- PHP;

- HTML/CSS slicing.

Trying to learn:

- Ruby/Ruby-on-Rails;

- Czech language.

If you wish to express your opinion, ask a question or report a bug, feel free to e-mail:dmitrykhudorozhkov@yahoo.com. Job offers are warmly welcome.

If you wish to donate - and, by doing so, support further development - you can send Dmitry a bonus through the Rentacoder.com service (registration is free, Paypal is supported). Russian users can donate to the Yandex.Money account 41001132298694.

-

Comments and Discussions