WMI and CIM Connections

WMI and CIM Connections in PowerShell: Windows Management Instrumentation (WMI) / Common Information Model (CIM) is the database that contains all…

Windows Management Instrumentation (WMI) / Common Information Model (CIM) is the database that contains all configurations for the Windows OS (CPU specs, BIOS versions, active user sessions, disk sectors).

PowerShell extracts this effortlessly.

# Get Operating System details and build version
Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object Caption, Version, BuildNumber

# Get hard drive capacities across the machine
Get-CimInstance -ClassName Win32_LogicalDisk | Where-Object { $_.DriveType -eq 3 } | 
    Select-Object DeviceId, 
        @{Name="Size(GB)"; Expression={$_.Size / 1GB -as [int]}}, 
        @{Name="FreeSpace(GB)"; Expression={$_.FreeSpace / 1GB -as [int]}}

(Note: Using custom Hash Tables in Select-Object @{Name=...; Expression=...} allows you to dynamically rename and do math on properties on the fly!)