Author Posts

March 24, 2016 at 7:35 am

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}}

March 24, 2016 at 7:37 am

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

March 24, 2016 at 7:46 am

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.

March 24, 2016 at 10:48 pm

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.