Skip to content

Get-ComputerInfo - takes as long to get 1 property as 183 properties #9234

Closed

Description

@HumanEquivalentUnit

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

Activity

  1. added
    Issue-Question
    on Mar 27, 2019
  2. tlsalex commented on Mar 27, 2019

    @tlsalex

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

  3. RichardSiddaway commented on Mar 27, 2019

    @RichardSiddaway

    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

  4. jeffbi commented on Mar 27, 2019

    @jeffbi

    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.

  5. added
    Issue-Enhancement
    WG-Engine-Performance
    Up-for-Grabs
    on Mar 27, 2019
  6. RichardSiddaway commented on Mar 28, 2019

    @RichardSiddaway

    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

  7. powercode commented on Apr 1, 2019

    @powercode
    Collaborator

    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.

  8. mklement0 commented on Feb 8, 2023

    @mklement0
    Contributor

    One good reason to add command/provider-specific filtering is performance (e.g., the -Filter parameter in provider cmdlets, and, as more direct analog, the -Property parameter of Get-AdUser), and that certainly applies here: You shouldn't have to wait seconds to retrieve a single piece of information.

  9. added
    Resolution-No Activity
    on Nov 16, 2023
  10. slycordinator commented on Feb 1, 2024

    @slycordinator

    Still valid:

    PowerShell 7.4.1

    PS C:\Users\USER> Measure-Command {Get-ComputerInfo -Property TimeZone} | Select -ExpandProperty TotalMilliseconds
    2049.3817
    PS C:\Users\USER> Measure-Command {Get-TimeZone} | Select -ExpandProperty TotalMilliseconds
    1.9275
    

    Windows PowerShell (5.1.19041.3930)

    PS C:\Users\USER> Measure-Command {Get-ComputerInfo -Property TimeZone} | Select -ExpandProperty TotalMilliseconds
    2498.4514
    PS C:\Users\USER> Measure-Command {Get-TimeZone} | Select -ExpandProperty TotalMilliseconds
    2.4808
    

    In both cases, Get-TimeZones completes about 1000 times faster than Get-ComputerInfo -Property TimeZone

  11. jeffbi commented on Feb 1, 2024

    @jeffbi

    This is unlikely ever to be fixed. Newer versions of PowerShell are open source and cross-platform, and the CIM code (along with a few Windows API function calls) are not portable to Linux or macOS.

    As I've said before, the original mandate was to collect all the data. Only later was it decided to add -Property, which selects from all the already-collected data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-EnhancementIssue-QuestionResolution-No ActivityUp-for-GrabsWG-Engine-Performance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions