Access WMI via Python from Linux

linux, python, wmi, wmi-query

Solution

You can use Impacket (https://github.com/CoreSecurity/impacket) that has WMI implemented in Python.

There are two examples that might be useful:

1) https://github.com/CoreSecurity/impacket/blob/master/examples/wmiquery.py: It allows to issue WQL queries and get description of the objects

2) https://github.com/CoreSecurity/impacket/blob/master/examples/wmiexec.py: A similar approach to psexec but executing commands through WMI

Problem

I'm looking for a way to access the WMI (Windows Management Instrumantation) from a Pythonscript remotely from a Linux machine (CentOS 6) Of course there is the python-wmi package, but it uses the Windows API which isn't available on Linux. I found the wmi-client-wrapper which should do something like that. But there is no documentation and even the example isn't working for me. The reason why I want to do this, is because I want to get all Useraccounts on the System remotely and store them in a Database. Maybe you have any other tipps how to do that. Thank you

Original source