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.

The voting/judging process has started for event 1 in the 2013 Scripting Games. What I’m going to be doing over the next few weeks is point out some of the things that I’ve noticed when judging. Some will be good things that I think you should adopt; others will be bad things that you should avoid. There even may be some interesting stuff to get you thinking.

First off is the use of the backtick as a line continuation:

Get-Process | ` sort Handles –Descending

You don’t need a backtick at this point. The pipe symbol acts as a line continuation marker so the backtick is redundant. All you need to do is this:

Get-Process | sort Handles -Descending

Its the same with commas. You don’t need to do this:

Get-Process | select Name, Id, ` Handles, CPU

because it works without the backtick

Get-Process | select Name, Id, Handles, CPU

You may see backticks used a lot in books but that is an attempt to reduce the width of the code to make it fit the page. We want you to be able to copy the code from the ebook and run it. The alternative is a line continuation marker which you would have to remove.

Bottom line – 99.9% recurring of the time you don’t need backticks as line continuation markers

This removes the setup and tear-down of the WSMAN connection. It suggests that the actual retrieval time for the CIM cmdlets should be reduced to 1749.540808 milliseconds for 100 accesses which is faster than the WMI cmdlets

It looks like the fastest way to access WMI information is across a CIM session. Next time we’ll look at running multiple commands

The 2013 Scripting Games kicked off during the PowerShell summit. Event 1 is open and you can submit entries up until 23:59:59 GMT on 29 April 2013. Voting on the entries starts at at midnight on 30 April.

You can enter and you can vote on the entries. This is a community games run by powershell.org – all are welcome.