title: PowerShell Add-Member to array items
body: <p>I'm trying to use the PowerShell Add-Member cmd on all the items in an array and then access the member I added later but it doesn't show up.</p>
  
  <p>You can see in the output of the below code that the NoteProperty appears to exist within the scope of the foreach statement but it doesn't exist on the same object outside of that scope.</p>
  
  <p>Any way to get this script to show <code>isPrime</code> on both calls to Get-Member?</p>
  
  <pre><code>$p = @(1)
  $p[0] | %{ add-member -inputobject $_ -membertype noteproperty -name isPrime -value $true; $_ | gm }
  $p[0] | gm
  </code></pre>
  
  <p>output</p>
  
  <pre><code>   TypeName: System.Int32
  
  Name        MemberType   
  ----        ----------   
  CompareTo   Method       
  Equals      Method       
  GetHashCode Method       
  GetType     Method       
  GetTypeCode Method       
  ToString    Method       
  isPrime     NoteProperty 
  
  
  CompareTo   Method      
  Equals      Method      
  GetHashCode Method      
  GetType     Method      
  GetTypeCode Method      
  ToString    Method 
  </code></pre>