title: Powershell Custom Objects: How To Acess NoteProperty of collected result
body: <p>Reading through an Article about custom Objects:</p>
  
  <p><a href="http://technet.microsoft.com/en-us/library/ff730946.aspx" rel="noreferrer">http://technet.microsoft.com/en-us/library/ff730946.aspx</a></p>
  
  <p>I wonder why i get a result for the individual entry: e.g $objAverage.Name</p>
  
  <p>while by  $colAverages.Name nothing is returened.
  Although with Get-Member both show the [System.Object] NoteProperty Name</p>
  
  <p>I would expect returning the all Names of my resultset in $colAverages.</p>
  
  <p>Code of the article:
  C:\Temp\base.txt</p>
  
  <pre><code>Name,AtBats,Hits
  Ken Myer,43,13
  Pilar Ackerman,28,11
  Jonathan Haas,37,17
  Syed Abbas,41,20
  Luisa Cazzaniga,22,6
  Andrew Cencini,35,11
  Baris Cetinok,19,4
  </code></pre>
  
  <p>Powershell:</p>
  
  <pre><code>$colAverages = @()
  
  $colStats =Import-Csv C:\Temp\base.txt
  
  foreach ($objBatter in $colStats)
    {
      $objAverage = New-Object System.Object
      $objAverage | Add-Member -type NoteProperty -name Name -value $objBatter.Name
      $objAverage | Add-Member -type NoteProperty -name BattingAverage -value ("{0:N3}" -f ([int] $objBatter.Hits / $objBatter.AtBats))
      $colAverages += $objAverage
    }
  
  $colAverages | Sort-Object BattingAverage -descending
  </code></pre>