locked
Why does a Select with no -Expand work? RRS feed

  • Question

  • Hello,

    The following works for me:

    Get-ADComputer -Filter * | Select @{l='computername';e={$_.name}} | Get-HotFix

    Why does this work without specifying a 'Select-Object -expand name'?  The object type from the Get-ADComputer is a 'ADComputer' and I thought to get Name to be a String which is what Get-HotFix needs I would need to do a -expand.  So does the HashTable automatically perform an -expand?


    Thanks for your help! SdeDot

    Thursday, January 17, 2013 10:02 PM

Answers

  • as I understand it that syntax generates a "calculated property" called -computername whose value is set to the .name property of each computer object coming down the pipe. Here's an explanation: http://technet.microsoft.com/en-us/library/ff730948.aspx

    That said, the name of the property is normally specified as name= or n= not l=. maybe l= is short for label=.


    Al Dunbar -- remember to 'mark or propose as answer' or 'vote as helpful' as appropriate.

    • Proposed as answer by Kazun Friday, January 18, 2013 6:10 AM
    • Marked as answer by SdeDot Friday, January 18, 2013 1:34 PM
    Friday, January 18, 2013 3:53 AM