PowerShell Get-CimInstance: Modern WMI Queries

PowerShell Get-CimInstance: Modern WMI Queries

PowerShell Tips Editor 4 min read
PowerShell Get-CimInstance: Modern WMI Queries

Asset inventory without logging into each PC, hardware audits across a data center, OS details pulled remotely in seconds — all of it depends on WMI, and PowerShell Get-CimInstance WMI is the modern way to query it. Get-CimInstance replaced the deprecated Get-WmiObject cmdlet and brings cleaner syntax, WinRM transport (instead of DCOM), and full PowerShell 7 compatibility. This post walks through the most useful WMI classes with practical examples for every sysadmin scenario.

Get OS and System Info

Start with Win32_OperatingSystem for the OS version, install date, and uptime. This is the foundation of most hardware inventory scripts.

Get-CimInstance -ClassName Win32_OperatingSystem |
    Select-Object Caption, Version, OSArchitecture, LastBootUpTime, InstallDate
Caption         : Microsoft Windows Server 2022 Datacenter
Version         : 10.0.20348
OSArchitecture  : 64-bit
LastBootUpTime  : 4/28/2026 6:00:00 AM
InstallDate     : 1/15/2025 9:22:00 AM

Get BIOS and Serial Number

The Win32_BIOS class provides the system serial number and BIOS version — essential for hardware tracking and warranty lookups.

Get-CimInstance -ClassName Win32_BIOS |
    Select-Object Manufacturer, Name, SerialNumber, SMBIOSBIOSVersion, ReleaseDate
Manufacturer       : Dell Inc.
Name               : Dell System BIOS
SerialNumber       : ABC1234
SMBIOSBIOSVersion  : 2.19.0
ReleaseDate        : 12/1/2024 12:00:00 AM

Get CPU and Memory Info

Win32_Processor returns CPU details per socket. For total RAM, query Win32_PhysicalMemory and sum the capacities — the values are in bytes, so divide by 1 GB for readable output.

# CPU info
Get-CimInstance -ClassName Win32_Processor |
    Select-Object Name, NumberOfCores, NumberOfLogicalProcessors, MaxClockSpeed

# Total RAM in GB
$ramGB = (Get-CimInstance -ClassName Win32_PhysicalMemory |
    Measure-Object -Property Capacity -Sum).Sum / 1GB
Write-Output "Total RAM: $([math]::Round($ramGB, 1)) GB"
Name                           Cores  Logical  Speed
----                           -----  -------  -----
Intel(R) Xeon(R) Gold 6248R    24     48       3000

Total RAM: 128.0 GB

Get Disk Information

Win32_LogicalDisk returns drive letter, size, and free space. Sizes are in bytes — convert to GB for the report. Filter by DriveType -eq 3 to get only local fixed disks (not network shares or removable media).

Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DriveType = 3" |
    Select-Object DeviceID,
        @{ N="SizeGB";    E={ [math]::Round($_.Size / 1GB, 1) } },
        @{ N="FreeGB";    E={ [math]::Round($_.FreeSpace / 1GB, 1) } },
        @{ N="UsedPct";   E={ [math]::Round((($_.Size - $_.FreeSpace) / $_.Size) * 100, 1) } }
DeviceID  SizeGB  FreeGB  UsedPct
--------  ------  ------  -------
C:        237.9   98.4    58.6
D:        1907.7  812.3   57.4

Query Remote Computer

Add -ComputerName to any Get-CimInstance call to query a remote machine. By default, CIM uses WinRM transport (WSMAN), which requires WinRM to be enabled on the target.

# Single remote machine
Get-CimInstance -ComputerName "server01" -ClassName Win32_OperatingSystem |
    Select-Object PSComputerName, Caption, LastBootUpTime

# Multiple machines from a list
$servers = @("server01", "server02", "server03")
Get-CimInstance -ComputerName $servers -ClassName Win32_BIOS |
    Select-Object PSComputerName, SerialNumber

For machines where DCOM is still required (legacy environments), create a CimSession with the DCOM protocol: New-CimSession -ComputerName "oldserver" -SessionOption (New-CimSessionOption -Protocol Dcom).

Filter CIM Results with -Filter

The -Filter parameter accepts WQL (WMI Query Language) WHERE clause syntax. Filtering at the source is much faster than pulling all records and filtering in PowerShell — especially on large WMI classes.

# Only running services
Get-CimInstance -ClassName Win32_Service -Filter "State = 'Running'" |
    Select-Object Name, StartMode, PathName

# Disks larger than 100 GB
Get-CimInstance -ClassName Win32_LogicalDisk -Filter "DriveType = 3 AND Size > 107374182400" |
    Select-Object DeviceID, @{ N="SizeGB"; E={ [math]::Round($_.Size/1GB,1) } }

Common Errors and Fixes

  • Get-WmiObject removed in PowerShell 7: Get-WmiObject does not exist in PowerShell 7 or on Linux/macOS. Replace every Get-WmiObject call with Get-CimInstance — the class names and most properties are identical. The only syntax difference is that -Filter in Get-CimInstance uses WQL syntax while Get-WmiObject accepted a -Query parameter for full WQL SELECT statements.
  • Remote CIM requires WinRM or DCOM: If -ComputerName fails with “Access is denied” or a connection error, first verify WinRM is running: Test-WSMan -ComputerName server01. If the remote machine only supports DCOM (old OS), create a CimSession with -SessionOption (New-CimSessionOption -Protocol Dcom) as a fallback.

Related Cmdlets / See Also

Wrapping Up

Get-CimInstance is your remote-ready, cross-platform gateway to Windows hardware and OS data — and it’s the only WMI cmdlet you should write in new scripts. As a next step, chain the CPU, RAM, disk, and BIOS queries above into a single function that accepts a computer name and returns a complete inventory object, ready to export across your entire environment.

Send-Item -To