title: Array as PSObject member powershell
body: <p>I am trying to remove what I thought was an element of an array that is a member of a PSObject.</p>
  
  <pre><code>$obj = New-Object psobject
  $obj | Add-Member -MemberType NoteProperty -Name member -Value @()
  $obj.member += $null
  $obj.member[0] = "A"
  $obj.member += $null
  $obj.member[1] = "B"
  </code></pre>
  
  <p>so far so good. $obj.member behaves like an array in that i can call individual element and convert to string using -join. However, when I try to remove an element, I find out that $obj.member is not an array at all. $obj.member|gm tells me it's a String and when I call $obj.member.removeRange(), I get an error:
  stating: [System.Object[]] doesn't contain a method named 'removeRange'.</p>
  
  <p>So.. it looks like a string, behaves like an array, and is actually an Object.</p>
  
  <p>I was under impression that if i define the value of the NoteProperty type member of an object as @(), that member will be an array--evidently this is not true, but never occurred to me as i was able to -join the elements.</p>
  
  <p>Please explain what is going on here.</p>
  
  <p>Ultimately, I am trying to have an Object member be an array, so I can add AND remove elements.</p>
  
  <p>Thanks!!</p>