I build Nyctale, a Windows diagnostic tool, so I read a lot of system data from PowerShell: memory, CPU, disk, battery. Most advice I found online says "WMI is slow, use CIM, or use performance counters". I wanted to know if that is true, so I measured it.
Setup: a 2018 laptop (Core i5-8250U), Windows 11 in French, Windows PowerShell 5.1, a normal non-administrator session. Each number is the median of 20 to 30 runs after one warm-up call (100 runs for the .NET counter). One machine, one language: use the script at the end to check yours.
Myth 1: Get-CimInstance is much faster than Get-WmiObject
Not on my machine:
| Query | Median |
|---|---|
Get-WmiObject Win32_OperatingSystem | 114 ms |
Get-CimInstance Win32_OperatingSystem | 116 ms |
They query the same WMI provider, so they cost the same. There are good reasons to prefer CIM (Get-WmiObject does not exist in PowerShell 7, and CIM gives you cleaner objects), but speed is not one of them.
Where the time really goes: the properties you ask for
This is the number that surprised me:
| Query | Median |
|---|---|
Get-CimInstance Win32_Processor | 1,059 ms |
Get-CimInstance Win32_Processor -Property Name,MaxClockSpeed | 13 ms |
Same class, same machine, 80 times faster. Some properties are expensive to compute (on this class, the live ones such as the load percentage), and by default you pay for all of them. If you only need the name and the maximum clock speed, say so with -Property:
# Slow: computes every property, including the live ones Get-CimInstance Win32_Processor # Fast: only what you need Get-CimInstance Win32_Processor -Property Name, MaxClockSpeed I did not test every class, so measure before you assume. But "ask only for the properties you use" is the cheapest optimization I found.
Formatted vs raw performance classes
WMI exposes performance data twice: Win32_PerfFormattedData_* (ready-made percentages) and Win32_PerfRawData_* (raw counters you compute from yourself).
| Query | Median |
|---|---|
Win32_PerfFormattedData_PerfOS_Memory | 285 ms |
Win32_PerfRawData_PerfOS_Memory | 17 ms |
Win32_PerfFormattedData_Counters_ProcessorInformation (_Total) | 286 ms |
Win32_PerfRawData_Counters_ProcessorInformation (_Total) | 28 ms |
The raw class is about 10 times cheaper. The formatted class has to take two samples to compute a rate, and you pay for that wait. The price of raw data is that you do the maths: read the counter twice, a known time apart, and compute the difference yourself. For a diagnostic that already measures over a few seconds, that is a good trade.
A trap on non-English Windows: counter names are translated
Get-Counter takes counter paths, and those paths are localized. On my French Windows:
Get-Counter '\Processor(_Total)\% Processor Time' # Get-Counter : The specified object was not found on the computer. Get-Counter '\Processeur(_Total)\% temps processeur' # works A script that works on your English machine fails on a French one. And Get-Counter is slow anyway: it took about 1,014 ms per call on my machine, since it samples over an interval.
Two ways around it:
- WMI classes have the same names in every language. This is what Nyctale does. There is a comment in my code saying exactly this: use the WMI classes, not
Get-Counter, because counter names are translated according to the language of Windows. Nyctale readsWin32_PerfRawData_PerfOS_Memoryat the start and the end of a measurement, to compute real paging activity. - .NET
System.Diagnostics.PerformanceCounteraccepted the English names on my French Windows 11:
$cpu = New-Object System.Diagnostics.PerformanceCounter('Processor', '% Processor Time', '_Total') $null = $cpu.NextValue() # the first read is only a baseline Start-Sleep -Milliseconds 200 $cpu.NextValue() # a real value | Query | Median |
|---|---|
PerformanceCounter.NextValue() (100 runs) | 0.57 ms |
| Creating the counter and the first read | 1.0 ms |
So it is the fastest option for a live graph. I only confirmed the English names on a French system, not on every language. I would still test it on yours.
What I could not read without admin rights
I ran these in my non-administrator session:
| Query | Result |
|---|---|
Win32_Battery, Win32_LogicalDisk | works |
root\wmi BatteryFullChargedCapacity | works |
root\wmi MSStorageDriver_FailurePredictStatus | "Not supported" |
Get-PhysicalDisk, then Get-StorageReliabilityCounter | access to the CIM resource was not available |
root\wmi MSAcpi_ThermalZoneTemperature | access denied |
So battery wear and basic system data are fine unelevated. Disk temperature and wear (the reliability counters) and thermal zones were not, on this machine.
I will be upfront about what this means for my own product. Nyctale reads the disk reliability counters (temperature and wear), so the installer build of Nyctale is built to request administrator rights (--uac-admin in my build script), while the Microsoft Store build is not. I would rather say it than claim a tool needs "no admin at all". If you can live without those readings, an unelevated tool is realistic. If you cannot, ask for elevation clearly.
What I would do
- Do not switch from WMI to CIM for speed. Switch because it is the supported cmdlet.
- Always pass
-Propertywhen you only need a few fields. - Prefer
PerfRawDataclasses overPerfFormattedDatawhen you can sample twice yourself. - Never hard-code
Get-Counterpaths if your software runs outside English systems. - Test your readings in a normal user session, not in the elevated terminal you develop in.
Reproduce it
function Bench($name, [scriptblock]$sb, $n = 20) { & $sb | Out-Null # warm-up $t = 1..$n | ForEach-Object { $sw = [Diagnostics.Stopwatch]::StartNew(); & $sb | Out-Null; $sw.Stop() $sw.Elapsed.TotalMilliseconds } | Sort-Object "{0,-50} median {1,8:N2} ms" -f $name, $t[[int]($n / 2)] } Bench 'CIM Win32_Processor (all properties)' { Get-CimInstance Win32_Processor } Bench 'CIM Win32_Processor -Property Name,MaxClockSpeed' { Get-CimInstance Win32_Processor -Property Name, MaxClockSpeed } Bench 'CIM PerfFormatted memory' { Get-CimInstance Win32_PerfFormattedData_PerfOS_Memory } Bench 'CIM PerfRaw memory' { Get-CimInstance Win32_PerfRawData_PerfOS_Memory } If your numbers are very different from mine, I would like to know.

