Format-Table behaviour in 5.1

Welcome Forums General PowerShell Q&A Format-Table behaviour in 5.1

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

 
Participant
8 months, 2 weeks ago.

  • Author
    Posts
  • #94959

    Participant
    Points: 0
    Rank: Member

    Prior to 5.1 (or maybe earlier), when results containing objects were displayed, the name of the field was displayed – e.g. VerifiedDomains in the example below.

    >$adtd=Get-AzureADTenantDetail ; $adtd
    
    ObjectId                             DisplayName            VerifiedDomains
    --------                             -----------            ---------------
    85b5ff1e-0402-400c-9e3c-0f9e965325d1 Coho Vineyard & Winery {class VerifiedDomain {...

    Now however, FT now 'simplifies' the name, e.g. VerifiedDomain as shown below

    >$adtd=Get-AzureADTenantDetail ; $adtd
    
    ObjectId                             DisplayName         VerifiedDomain
    --------                             -----------         --------------
    a34d9988-c5e2-4aff-86f5-54a1b18c68bd Contoso M365x295334 M365x295334.onmicrosoft.com

    This renders simple display of objects – e.g.

    >$adtd

    useless for exploratory scripting – the object returned doesn't have a VerifiedDomain field, the field is VerifiedDomains.

    Is there a workaround or setting to revert to the older behaviour? – currently I'm doing

    >$adtd | fl

    or

    >$adtd | gm

    to see the actual fields

    Thanks for any guidance

  • #94960

    Keymaster
    Points: 1,619
    Helping HandTeam Member
    Rank: Community Hero

    There are some tricks about the formatting system. This isn't a 'behavior change,' per se – it's how the thing works.

    If it isn't given a predefined formatting view (from a .ps1xml file), it uses property names (they're technically not "fields"). If it _is_ given a formatting view, then it uses whatever's defined in that view. That's why you see column. headers in Get-EventLog output, for example, which aren't property names.

    So at some point you wound up with a formatting view for that object type, and PowerShell is displaying it. Either that, or you had one before, and a module update or something -changed- the formatting view to what you see now. Get-Member is the One True Way to see the actual property names; tables are meant as a _view_, not as a canonical source of programming information. Much like in a report, tables may "prettify" things. And it happens on a lot of objects you may just have never noticed.

    • #94963

      Participant
      Points: 0
      Rank: Member

      Thanks – it's the first time I've noticed it with the AzureAD cmdlets, so there probably has been a change in the AzureAD module formatting view – Get-Member it is then.

The topic ‘Format-Table behaviour in 5.1’ is closed to new replies.