Comment on Checking for USB Devices

Both work … Get-WmiObject -Class Win32_PnpEntity | Select-Object -ExpandProperty Caption Get-CimInstance -ClassName Win32_PnpEntity | Select-Object -ExpandProperty Caption WMI over CIM in most cases is habit or on PSv2 and below where CIM Does not exist. Folks are just far more use to WMI and CIM is only really a thing for the more recent OS Windows versions. Well, even if you are using the latest OS and PS version. You must always plan for the lowest common denominator in your enterprise. So, get in the habit, for now of using branching code. Meaning always check for OS and PS version and take the most prudent branch. However, for PSv6 (PSCore cross platform) only CIM works, as there Get-WMI* is not in PSCore. I still find much WMI far more performant that CIM and on many things (not in this simple case), and in many cases WMI brings back more than CIM. Odd, I know but it is what it is. The primary reason for CIM over WMI is WMI(DCOM) is not firewall friendly, well that and it’s where things are in PSCore cross platform. The primary reason for WMI is backwards compatibility. ‚’ ‚’ ‚’ ‚’ ‚ ‚’

GD Star Rating