WMIC – A Hidden Gem

Often times I find myself applying “developer-type” solutions to IT administrator problems.  Naturally I was excited as PowerShell a.k.a Monad a.k.a Poshwas gaining notoriety.  I had visions of a tool that would let me peek into services, filesystems, performance counters, etc. for all of my servers including database, application, web, etc.  Much to my dismay, I quickly found that PowerShell only works locally!  Total bummer, but it is a 1.0 product, so I am sure Microsoft had to do some feature triage. Things like AD and WMI took a back seat as there are other ways to get that data.

This means that the best way to query a server for administrative details such as OS version, patches, CPU, memory, running processes, services, etc is still to use Windows Management Instrumentation (WMI).  In my opinion, using PowerShell 1.0 to call WMI is using a sledgehammer to kill a fly.  This is fine, and it will certainly do the trick.  However, if you don’t already know how to wield a sledgehammer, you may be explaining to your boss why it took 4 days to get a working script that one can do without PowerShell in 5 minutes.  Enter WMIC – the command line tool for WMI.

It is amazing this thing doesn’t get more play, because it is awesome and comes built into most recent versions of Windows including Windows XP.   WMIC is simple, elegant and very powerful.  You can accomplish a tremendous amount in just one command line.  This is much more straightforward, in my opinion, that using .NET or even PowerShell to crack open the functionality and data contained within WMI.

To show you how easy and awesome WMIC is, I invite you to try the following steps. Note there is no step to download anything because as long as you are using any modern version of Windows, it is included in the OS:

  • Go to a command prompt and type the following command
  • C:\Documents and Settings\your_id> WMIC

  • This will bring you to the WMIC command prompt. Now type
  • wmic:root\cli> process

Notice the horizontal scrollbar in your results — there is a lot of information provided! This is essentially task manager on steriods. Better yet, it can be scripted out to a text file… on a schedule… etc… Pause for a minute and think about all of the things you can do with this. Now get ready to have your socks rocked off by the number of different items you can get information on. We used the “process” command to get information about the active running processes, but check this out (from within the wmic command prompt):

  • At the WMIC command prompt type
  • wmic:root\cli> /?

Have fun exploring!!! Please post any comments here of useful tricks you have found using WMIC. Here are some other useful resources you may want to check out for more information on WMIC:

http://technet.microsoft.com/en-us/library/bb742610.aspx

http://www.net-security.org/dl/articles/WMIC.pdf

    About these ads

    6 Responses

    1. http://quux.wiki.zoho.com/WMIC-Snippets.html

      Very handy WMIC cheatsheet with plenty of cut’n’paste solutions.

    2. yes I agree. Why is there not more usage of these types of products and services? MS seems to of abstracted to much and now folks are not aware of or have lost touch with the true OS.

      good points scott thanks for taking the time to posts the info!

    3. [...] 2009 by codeslammer This is a quick post to provide some detail on using the wildcard search for WMIC.  This feature of the command structure will allow you to use like conditions in a where [...]

    4. tried the /output command ; no field separators.

    5. Hi there, i read your blog from time to time and i own
      a similar one and i was just curious if you get a lot of
      spam comments? If so how do you reduce it, any plugin or anything you can recommend?
      I get so much lately it’s driving me insane so any help is very much appreciated.

    6. Use Local Keywords on Your for local business that is small scale.
      We will now begin the practical optimization you should take advantage
      of this. If you are developing a webpage, therefore, you generate
      additional links back to your site. I figure by maintaining this hub and
      updating it I’d be not only inspired to write more, but be able refining the way that results appear on the search engine results page. Read about the Off-Page elements to writing articles so they can help you to make money online. Google tweaks its algorithms for displaying search results more than once allow hubbers to click on your hubs and read through the bottom of the article. We have great relationships with all of our clients and they disclose at the affiliate page of hubpages to make sure they were right. It should be noted that our definition of wavefunction is an ?expression for the amplitude of the particle wave? (wave function, Encyclopedia Britannica, 2008) Since a wavefunction Us. I wrote about Why Market with a very percentage of 10% even clicking over to the second and third pages. That is with talking face to face.

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s

    Follow

    Get every new post delivered to your Inbox.

    %d bloggers like this: