---
title: "Get-WmiObject: Query WMI for Computer Information"
description: "Learn to use PowerShell to query WMI and retrieve computer information with the Get-WmiObject cmdlet."
canonical: "https://adamtheautomator.com/get-wmiobject/"
---

# Get-WmiObject: Query WMI for Computer Information

> Learn to use PowerShell to query WMI and retrieve computer information with the Get-WmiObject cmdlet.

Source: https://adamtheautomator.com/get-wmiobject/

---

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/)

![Get-WmiObject: Query WMI for Computer Information](https://adamtheautomator.com/wp-content/uploads/2019/06/get-wmiobject-Get-WmiObject.jpg)

# Get-WmiObject: Query WMI for Computer Information

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

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

Tags:[PowerShell](/tag/powershell/)[WMI](/tag/wmi/)

Table of Contents

*   [Discovering Classes with Get-WmiObject](#discovering-classes-with-get-wmiobject)
*   [Getting WMI Properties](#getting-wmi-properties)
*   [Finding WMI Properties](#finding-wmi-properties)
*   [Invoking WMI Methods](#invoking-wmi-methods)
*   [WMI, DCOM, and PowerShell Remoting](#wmi-dcom-and-powershell-remoting)

Whenever we need to discover just about any information about a Windows computer and it’s components, we can do so with `Get-WmiObject`.

Not only reading, by leveraging WMI methods, `Get-WmiObject` can also run actions on local or remote systems as well. This cmdlet is one of a couple in PowerShell that can work with the WMI repository to make managing lots of systems a whole lot easier.

## Discovering Classes with Get-WmiObject

At it’s most basic this cmdlet can query information from a local computer. All you’ll need to know is the namespace (probably `root\cimv2` which is default) and the WMI class where the information you’re looking for is located.

There are thousands of classes, and you probably don’t know which class you’d like to use yet. Using `Get-WmiObject`, we can query all of the available classes in a namespace. Using `Get-WmiObject -List`, you’ll be able to see all of the classes in the `root\cimv2` namespace. If you need to check classes in another namespace, you can always use the `Namespace` parameter along with that as well.

```powershell
PS> Get-WmiObject -List

NameSpace: ROOT\cimv2

Name				Methods	Properties
CIM_Indication		{}		{CorrelatedIndications, IndicationFilterName, IndicationIde...
CIM_ClassIndication	{}    	{ClassDefinition, CorrelatedIndications, IndicationFilterNa........
```

## Getting WMI Properties

Once you’ve got the class, it’s then time to investigate and see what properties are in that class. Perhaps I’d like to see what operating system a computer is running. I might be building a report and would like to see what a _remote_ machine is running. `Get-WmiObject` has a `ComputerName` parameter where you can specify one or more remote computers rather than locally.

My remote computer is a domain controller called DC. I’ll look at the `Win32_OperatingSystem` class to see what properties are in there.

```powershell
PS> Get-WmiObject -ComputerName DC -Class Win32_OperatingSystem

SystemDirectory : C:\Windows\system32
Organization    :
BuildNumber     : 9600
RegisteredUser  : Windows User
SerialNumber    : 00252-00108-14656-AA864
Version         : 6.3.9600
```

That’s useful information, but I don’t see the operating system name. Similar to many other PowerShell outputs, you do not see all of the properties. For that, we’ll have to use `Select-Object` to return all of the properties.

```powershell
Get-WmiObject -ComputerName DC -Class Win32_OperatingSystem | Select-Object -Property *
```

I can now see a property called `Caption` that lets me know the version of Windows.

```powershell
PS> (Get-WmiObject -ComputerName DC -Class Win32_OperatingSystem | Select-Object -Property *).Caption Microsoft Windows Server 2012 R2 Standard
```

## Finding WMI Properties

What if you aren’t looking for a specific property but rather a property that matches a specific value. For example, we can query all of the instances in the `CIM_DataFile` class, but that would return every file on the system! Instead, we can filter instances by value using either the `Filter` or the `Query` parameter. Let’s go over both.

Using the `CIM_DataFile` as an example, maybe I want only to find instances that represent compressed files. Since the `Compressed` property is a property on each instance and it’s a boolean value, I can use the `Filter` parameter to send the filter directly to the WMI provider only returning instances that have a `Compressed` property of `True`.

```powershell
Get-WmiObject -Class CIM_DataFile -Filter "Compressed = 'True'"
```

If you know [WQL](https://msdn.microsoft.com/en-us/library/aa392902%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396), you can also select the class and specify the “filter” on your own by crafting your own WQL query as well.

```powershell
Get-WmiObject -Query "SELECT * FROM CIM_DataFile WHERE Compressed = 'True'"
```

## Invoking WMI Methods

`Get-WmiObject` not only can read information from WMI, but it can also facilitate invoking WMI methods. One common WMI method that’s invoked is the `Create` method on the `Win32_Process` class. There are a few different ways to invoke WMI methods such as using `Invoke-WmiMethod`, but this can be done with `Get-WmiObject` as well. We just need to capture a WMI instance and then call the method on that object.

Here’s an example of remotely starting notepad.exe on a remote computer. As a bonus, we’re using an alternate credential to do so as well!

```powershell
$cred = get-credential
$process = Get-WmiObject -Query "SELECT * FROM Meta_Class WHERE __Class = 'Win32_Process'" -namespace "root\cimv2" -computername 'FOO' -credential $cred $process.Create( "notepad.exe" )
```

## WMI, DCOM, and PowerShell Remoting

One last thing to point out is that this cmdlet’s successor: `Get-CimInstance`. Although `Get-CimInstance` does provide some advantages to using [PowerShell Remoting](https://adamtheautomator.com/psremoting/ "PowerShell Remoting") as it’s default remote connectivity protocol, `Get-WmiObject` is sometimes easier to use.

`Get-WmiObject` uses DCOM to communicate with remote computers and is also usually available as well. Otherwise, you’ll need to enable PowerShell Remoting on remote endpoints when wanting to use `Get-CimInstance` via WSMAN.

For a full breakdown, check out the [Microsoft documentation](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-wmiobject?view=powershell-5.1).

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fget-wmiobject%2F&text=Get-WmiObject%3A%20Query%20WMI%20for%20Computer%20Information)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fget-wmiobject%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fget-wmiobject%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2024/10/aa54f7e6-4835-4776-afa0-5e0977ad23b8.webp)

### [PowerShell CIM Classes: Your Gateway to Windows System Management](/powershell-cim-master-guide/)

Master PowerShell's CIM capabilities to query and manage Windows systems like a pro. Learn why CIM is the future of Windows system management and how to leverage its power in your automation tasks.

![](https://adamtheautomator.com/wp-content/uploads/2019/07/photo-1558494949-ef010cbdcc31.jpg)

### [PowerShell WMI: Automate Windows Tasks](/powershell-wmi/)

Harness the power of PowerShell WMI to automate thousands of tasks on Windows computers.

![](https://adamtheautomator.com/wp-content/uploads/publisher/3ec5d9c85b2b81d9ab7cd5dbb6caf044/21b786d67f19d1813150edf9871e36ead78714b63880de8c6161c7fde11a9769.webp)

### [Pktmon: Capture Windows Traffic Without a Third-Party Driver](/pktmon-capture-windows-traffic/)

Use the in-box Windows Pktmon tool to capture packets and packet-drop reasons, then convert the ETL to pcapng and text for offline analysis.

## 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/)
