Hash table question

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

  • Author
    Posts
  • #36949

    nick c
    Participant

    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.

    Ex:

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

    vs

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

  • #36950

    Dave Wyatt
    Moderator

    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.)

  • #36951

    Don Jones
    Keymaster

    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.

  • #36959

    nick c
    Participant

    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.

You must be logged in to reply to this topic.