Powershell: Get-ComputerInfo - takes as long to get 1 property as 183 properties

Created on 27 Mar 2019  路  5Comments  路  Source: PowerShell/PowerShell

Get-ComputerInfo returns 183 properties in 7 seconds.

Get-ComputerInfo -Property TimeZone returns 1 property in .. 7 seconds.

Get-TimeZone runs in 0.0015 seconds. and returns more detailed information.

Can it run faster, if asked for less data?

Environment:

Name                           Value
----                           -----
PSVersion                      6.1.0
PSEdition                      Core
GitCommitId                    6.1.0
OS                             Microsoft Windows 10.0.14393 
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Issue-Enhancement Issue-Question Up-for-Grabs WG-Engine-Performance

All 5 comments

Agree with you , I also want to know the answer , maybe we need to use WMI

Looking at the data returned I think its already using WMI. I suspect the speed issue is because its gathering all the data and then filtering down to the properties you asked for

@RichardSiddaway It is using WMI (well, CIM if I recall correctly). At the time the cmdlet was originally written, the mandate was to collect and display _all_ the data. The ability to report a single property was added kind of at the last minute and the decision at the time was to continue collecting all, then select to one to report.

WMI was Microsoft's first CIM implementation. CIM (in PowerShell terms) was the methodology introduced in PowerShell v3 including CIM sessions
These days CIM and WMI are interchangeable unless you're talking about the WMI or CIM cmdlets

I'm not sure why the designers of the cmdlet added property filtering capabilities. That is already available in Select-Object, so it seems like something that shouldn't have been there in there first place. If you read the source, it just gets everything, and if you only want a subset of the properties, it creates a psobject and populates it with those.

Feature creep in my book.

Was this page helpful?
0 / 5 - 0 ratings