title: Difference between select-object and using foreach on the same object
body: <p>Can someone please help me understand the difference between the below two pieces of code . Why are the results different for both . I each case i am selecting the same property (name) :</p>
  
  <p>Code 1 :</p>
  
  <pre><code>$obj = Get-Service | Where-Object {$_.Status -eq "Running"} | foreach-object  {$_.Name} | select -first 3
  foreach ( $item in $obj ) { write-output "Name is : $item" }
  Output :
  Name is : AeLookupSvc
  Name is : Appinfo
  Name is : AudioEndpointBuilder
  </code></pre>
  
  <p>Code 2 :</p>
  
  <pre><code>$obj = Get-Service | Where-Object {$_.Status -eq "Running"} | select -first 3 name
  foreach ( $item in $obj ) { write-output "Name is : $item" }
  Output :
  Name is : @{Name=AeLookupSvc}
  Name is : @{Name=Appinfo}
  Name is : @{Name=AudioEndpointBuilder}
  </code></pre>