Apr 21

WMI is microsoft’s attempt at making SNMP “better”. Whether they succeed or fail at that is subjective, but querying wmi from a non windows hosts has been a problem in the past and has required lots of hoops and weird proxies. No more! wmic is a command line wmi client that you can install on linux. On a debian based host, just use

apt-get install wmi-client.

Once installed, a simple test like the following should get you lots of wmi goodies. Just remember that you need to use a valid windows account that has permissions to query wmi for this to work.

wmic -U $DOMAIN/$USER%$PASSWORD //$SERVER “Select * from Win32_Service”

$DOMAIN is your AD domain where your user exists
$USER is your username
$PASSWORD is your users password
$SERVER is the server name

A real world example

jason@workstation:~$ wmic -U AD/jason%ohnoes //server.cyborgworkshop.org “Select ProcessID,Started,State from Win32_Service where Name=\”Dhcp\”"

Note that I escaped (\) the quotes on DHCP. It’s important. Do it.

Outputs

CLASS: Win32_Service
Name|ProcessId|Started|State
Dhcp|1196|True|Running

2 Responses

  1. Jim Says:

    Was hopeful but apt-get install returns Unable to locate package wmi-client

    This guy seems to know why though I don’t fully understand what he is talking about

    http://www.mikepalmer.net/archives/134

  2. jason Says:

    It was removed from the samba package for some reason, but zenoss still maintains a version that you can download from zenoss.com

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.