---
title: "Python WMI: Query WMI on Remote Computers with Linux"
description: "Learn to use Python for querying WMI on remote computers from a Linux system, such as Ubuntu."
canonical: "https://adamtheautomator.com/python-wmi/"
---

# Python WMI: Query WMI on Remote Computers with Linux

> Learn to use Python for querying WMI on remote computers from a Linux system, such as Ubuntu.

Source: https://adamtheautomator.com/python-wmi/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Python WMI: Query WMI on Remote Computers with Linux](https://adamtheautomator.com/wp-content/uploads/2019/06/query-wmi-linux-python-python.png)

# Python WMI: Query WMI on Remote Computers with Linux

[![](https://secure.gravatar.com/avatar/d0b9d42e21e5622713f8b693aa5c0f9244d5f7dd200ed29b8398f52dee5de337?s=192&d=mm&r=g)Adam Bertram](https://adamtheautomator.com/author/adam-bertram/)18 June 20191 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[Linux](/tag/linux/)[Python](/tag/python/)[WMI](/tag/wmi/)

Table of Contents

*   [Downloading WMIC on Linux](#wmic-on-linux)
*   [WMI in Python](#wmi-in-python)

I’ve recently been playing with Ansible quite a bit and, unfortunately, it’s only available on Linux. Being a big Windows guy, I’ve had to learn a ton about how Linux and Python interact with Windows. My goal was to get my Ubuntu Linux box using Python to query WMI. Let’s break it down!

Related:[Using WMI in PowerShell](https://adamtheautomator.com/python-wmi/)

## Downloading WMIC on Linux

The first task was to query a common WMI class on a Windows box. To do this on Linux, we need to download and compile the WMIC package. To do this, check out this [GitHub Gist](https://gist.github.com/rickheil/7c89a843bf7c853997a1). For anyone too lazy to click the link, here’s what to run to make it happen.

```bash
dpkg -i libwmiclient1_1.3.14-3_amd64.deb
dpkg -i wmi-client_1.3.14-3_amd64.deb

## Test a query to a remote computer
wmic -Utestuser%tstpass //<remote IP> "SELECT * FROM Win32_OperatingSystem"
```

If you see the properties and values of Win32\_OperatingSystem you’re good!

## WMI in Python

The next step is to get a WMI module for Python. I chose to use the _wmi-client-wrapper_ Python module. To get this installed:

```bash
> sudo pip install wmi-client-wrapper
```

Once installed, create a Python script to test it out. Here’s what mine looked like assuming you have Python 2.x installed. If you have Python 3.x your top line will probably read

```python
#!/usr/bin/python3
#!/usr/bin/python

import wmi_client_wrapper as wmi
wmic = wmi.WmiClientWrapper(username="localaccount",password="localpassword",host="<HostNameOrIpAddress>",)
output = wmic.query("SELECT * FROM Win32_Processor")
print(output)

## Save this as <FileName>.py and mark is as executable:
chmod +x <FileName>.py
## Then, we can execute the script to see if it brings back the Win32_Processor class.

[{'L2CacheSize': '0', 'VMMonitorModeExtensions': False, 'ConfigManagerErrorCode': '0',  'VoltageCaps': '0', 'PowerManagementSupported': False, 'LoadPercentage': '1',  'CreationClassName': 'Win32_Processor', 'Version': '', 'Role': 'CPU', 'CpuStatus': '1',  'SecondLevelAddressTranslationExtensions': False, 'Revision': '11527', 'Status': 'OK',  'PNPDeviceID': None, 'L2CacheSpeed': '0', 'AddressWidth': '64',  'ConfigManagerUserConfig': False, 'ErrorCleared': False, 'ProcessorId': '0F8BFBFF000206D7',  'ProcessorType': '3', 'DeviceID': 'CPU0', 'CurrentVoltage': '12', 'CurrentClockSpeed':  '2600', 'Manufacturer': 'GenuineIntel', 'Name': 'Intel(R) Xeon(R) CPU E5-2670 0 @ 2.60GHz',  'InstallDate': None, 'Level': '6', 'SocketDesignation': 'None', 'NumberOfCores': '1',  'Caption': 'Intel64 Family 6 Model 45 Stepping 7', 'StatusInfo': '3', 'Architecture': '9',  'UniqueId': None, 'PowerManagementCapabilities': 'NULL', 'OtherFamilyDescription': None,  'Description': 'Intel64 Family 6 Model 45 Stepping 7', 'NumberOfLogicalProcessors': '1',  'Family': '179', 'ErrorDescription': None, 'UpgradeMethod': '6', 'SystemName': 'HOSTNAME',  'LastErrorCode': '0', 'ExtClock': '8000', 'Stepping': None,  'VirtualizationFirmwareEnabled': False, 'MaxClockSpeed': '2600', 'L3CacheSize': '0',  'L3CacheSpeed': '0', 'Availability': '3', 'SystemCreationClassName': 'Win32_ComputerSystem',  'DataWidth': '64'}]
```

Yay! The output is JSON and is pretty gnarly at this point but, for now, I just wanted to get this going. I hope this helps anyone trying to get Python to query WMI on a remote computer on Linux!

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fpython-wmi%2F&text=Python%20WMI%3A%20Query%20WMI%20on%20Remote%20Computers%20with%20Linux)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fpython-wmi%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fpython-wmi%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2021/12/Creating-Statistical-Plots-with-the-Seaborn-Python-Library.jpg)

### [Creating Statistical Plots with the Seaborn Python Library](/seaborn-python/)

Are you still using Excel to generate statistical plots? Perhaps it’s time to ditch it and switch to the Seaborn Python library to create many beautiful plots.

![](https://adamtheautomator.com/wp-content/uploads/2019/08/tux-158547_1280.png)

### [Connect to SQL Server from Linux with ODBC](/connect-to-sql-server-from-linux/)

Set up an ODBC connection to run queries on a Microsoft SQL Server from Linux in this step-by-step guide.

![](https://adamtheautomator.com/wp-content/uploads/2026/02/featured_image-3.webp)

### [How to Ace the Modern Coding Interview as a SysAdmin](/ace-modern-coding-interview-sysadmin/)

Master coding interviews for sysadmin and DevOps roles with practical preparation strategies. Learn Python, Bash, and platform-specific techniques that translate your operational experience into interview success.

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
