Hash table question

This topic contains 3 replies, has 3 voices, and was last updated by Profile photo of nick c nick c 6 months, 1 week ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #36949
    Profile photo of nick c
    nick c

    I'm confused on when I should be using a Name vs a Label key when constructing my hash tables. I don't know the difference between the two.
    I'm currently going through the Powershell in a Month of Lunches book by the way.


    gsv | select name,status,@{name='CanShutDown';e={$_.canshutdown}}


    gsv | select name,status,@{label='CanShutDown';e={$_.canshutdown}}

    Profile photo of Dave Wyatt
    Dave Wyatt

    They may be interchangeable, but I typically use Name for Select-Object, and Label for the Format-* commands (because that's how I learned them.)

    Profile photo of Don Jones
    Don Jones

    In v1. Select-Object used Name and Format commands used Label. Nobody was clear on the difference – it came down to different developers not talking to one another. So in v2, they just made either work in any situation. There's no functional difference.

    I tend to use "n" for name because "l" for label is too easy to mistake for a digit 1.

    Profile photo of nick c
    nick c

    Thank you for the clarification! I've been scratching my head on this one and asking around the office but no one seemed to know.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.