WMI vs CIM speed tests–the final round

As a final test I want to see what happened when I ran multiple commands against the remote machine.

PS> 1..100 |
foreach {
Measure-Command -Expression{1..100 | foreach {
Get-WmiObject -Class Win32_ComputerSystem -ComputerName W12SUS;
Get-WmiObject -Class Win32_OperatingSystem -ComputerName W12SUS;
Get-WmiObject -Class Win32_LogicalDisk -ComputerName W12SUS}}
} |
Measure-Object -Average TotalMilliseconds

Count    : 100
Average  : 6986.797156
Sum      :
Maximum  :
Minimum  :
Property : TotalMilliseconds

PS> 1..100 |
foreach {
Measure-Command -Expression{1..100 | foreach {
Get-CimInstance -ClassName Win32_ComputerSystem -ComputerName W12SUS;
Get-CimInstance -ClassName Win32_OperatingSystem -ComputerName W12SUS;
Get-CimInstance -ClassName Win32_LogicalDisk -ComputerName W12SUS}}
} |
Measure-Object -Average TotalMilliseconds

Count    : 100
Average  : 8430.833188
Sum      :
Maximum  :
Minimum  :
Property : TotalMilliseconds

 

PS> $sess = New-CimSession -ComputerName W12SUS
PS> 1..100 |
foreach {
Measure-Command -Expression{1..100 | foreach {
Get-CimInstance -ClassName Win32_ComputerSystem -CimSession $sess;
Get-CimInstance -ClassName Win32_OperatingSystem -CimSession $sess;
Get-CimInstance -ClassName Win32_LogicalDisk -CimSession $sess}}
} |
Measure-Object -Average TotalMilliseconds

Count    : 100
Average  : 3460.203938
Sum      :
Maximum  :
Minimum  :
Property : TotalMilliseconds

WMI is slightly faster than CIM but using a CIM session is by far and away the fastest.

My conclusion is that WMI and CIM are comparable, with WMI having a slight edge for speed. If you want to run multiple commands against a remote machine you need to use a CIM session as it is way faster.

This entry was posted in PowerShell and WMI, PowerShell V3. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s