Default Cmdlet Output vs Get-member Properties

Welcome Forums General PowerShell Q&A Default Cmdlet Output vs Get-member Properties

This topic contains 2 replies, has 2 voices, and was last updated by

1 year, 11 months ago.

  • Author
  • #72385

    Topics: 4
    Replies: 6
    Points: 0
    Rank: Member


    I am trying to get an idea behind the scenes of default output vs get-member property results.


    Test-Connection -ComputerName   -- gives following ouput 
    Source   Destination  IPV4Address  IPV6Address  Bytes Time(ms)
    --        --            --           --          --     --

    Test-Connection | Get-Member -MemberType Property

    TypeName: System.Management.ManagementObject#root\cimv2\Win32_PingStatus

    Name MemberType Definition
    ---- ---------- ----------
    Address Property string Address {get;set;}
    BufferSize Property uint32 BufferSize {get;set;}
    NoFragmentation Property bool NoFragmentation {get;set;}
    PrimaryAddressResolutionStatus Property uint32 PrimaryAddressResolutionStatus {get;set;}
    ProtocolAddress Property string ProtocolAddress {get;set;}
    ProtocolAddressResolved Property string ProtocolAddressResolved {get;set;}
    RecordRoute Property uint32 RecordRoute {get;set;}
    ReplyInconsistency Property bool ReplyInconsistency {get;set;}
    ReplySize Property uint32 ReplySize {get;set;}
    ResolveAddressNames Property bool ResolveAddressNames {get;set;}
    ResponseTime Property uint32 ResponseTime {get;set;}
    ResponseTimeToLive Property uint32 ResponseTimeToLive {get;set;}
    RouteRecord Property string[] RouteRecord {get;set;}
    RouteRecordResolved Property string[] RouteRecordResolved {get;set;}
    SourceRoute Property string SourceRoute {get;set;}
    SourceRouteType Property uint32 SourceRouteType {get;set;}
    StatusCode Property uint32 StatusCode {get;set;}
    Timeout Property uint32 Timeout {get;set;}

    I have to cut few results due to length, but the point is i couldn't find the default output properties (except 2) in the GM list. What am i missing here? Appreciate your wisdom and time!


  • #72397

    Topics: 13
    Replies: 4872
    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    You have to understand how the formatting system works – it constructs the default display, and can provide different column headers than the underlying property names. It can also create on-the-fly calculated properties. It may be easier to run your command and pipe it to

    | Format-list *

    As you'll then bypass the default view and just get the raw dump, a la Get-Member, but including property values. There's a whole chapter in "Learn Windows PowerShell in a Month of Lunches" on this, as it's one of the many common "gotchas" people run into with PowerShell.

  • #72433

    Topics: 4
    Replies: 6
    Points: 0
    Rank: Member

    Thanks for prompt reply. I see what you are saying. So, the default output is entirely upto Microsoft Powershell Team to give viewers a quick meaningful results by calculating and formatting.

    The time I realized to learn powershell, most people recommended your "Learn Windows Powershell in a Month of Lunches" book, It was awesome so far. Day-5 is in the progress..

    Anyways, Thank you so much. It would be wise to wait till completion of entire book and post Questions.

The topic ‘Default Cmdlet Output vs Get-member Properties’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort