This isn’t so much a post as an extended pingback. This Post by Jeffrey Snover on the PowerShell Team Blog explains how to use the -expandproperty parameter of the select-object cmdlet.
I had never noticed that parameter and was also annoyed by writing this all the time:
get-something | foreach {$_.SomeProperty}
It was an idiom that I was using a lot that felt like it didn’t fit.</p> <p>As he points out, this can be replaced with the non-looping:
get-something | select-object -expandProperty SomeProperty
It’s longer if you don’t use aliases (and prefix-shortened parameternames), but I think it reads a lot better.
Let me know what you think. Was this a surprise to you, or have you used the -expandProperty parameter before?
Mike
P.S. You should definitely follow the PowerShell Team Blog…it is always worthwhile.