Monday, October 6, 2008

WMI/DCOM from Linux

Don't know why this was so tough to Google for, but the solution for WMI queries to a Windows box from Linux is right here.

From the README:
DCOM/WMI client implementation for Linux.
andrzej.hajda@wp.pl, 2006-2007

ABOUT

This implementation of DCOM/WMI client is based on Samba4 sources.
It uses RPC/DCOM mechanism to interact with WMI services on
Windows 2000/XP/2003 machines.
It contains also winexe - program to remote execution Windows commands remotely from Linux box.
Additional info about winexe at http://eol.ovh.org/winexe/.


  bin/wmic - WMI simple client, it queries server using ExecQuery WMI method,
sample usage:
wmic -U domain/user%password //host "select Name from Win32_Process"
Program is at early stage of development and there are many bugs.
To retrieve more debug info use switch "-d number", where bigger number
corresponds to bigger output (I am using "-d 99" :) )
bin/wmis - WMI test suite. Currently it does only following things:
- Creates directory remotely using Win32_Process.Create("cmd.exe /C mkdir C:\wmi_test_dir_tmp").
- Executes ExecNotificationQuery for monitoring file create/delete events in this directory.
- Waits for 4 notifications and display their types.
wmi/_pywmi.so - Samba wrapper for python, together with wmi/pywmi.py and ../pycom/* modules can be used
to run zenwin on Linux.
bin/winexe - Remote windows commands execution.
Sample usage:
winexe -U domain/user%password //192.168.0.3 "ipconfig /all"


WMIC, which is really what I was looking for, works great. There are also Python modules, which I haven't tried yet.

2 comments:

ewall said...

Thanks for posting this -- like you apparently had to, I was searching Google for a while trying to find the wmic command I use on my Zenoss server!

Anonymous said...

Hi,

do you have any additional informations about the wmic programm for linux ?
Do you have informations about setting values or taking actions on the windows host,
like restarting services, setting network options or similar?
Is it possible with wmic?
Do you know any addtional informations, who used the programm and wrote about
his experiences with it?