title: Removing element from .NET array .remove method not working as expected (Powershell)
body: <p>I have some code where I'm trying to use the .NET way of working with arrays in Powershell and the .remove method is not removing the element I want (processname "wssm" in examples 2 and 3). I'm doing something wrong and I'm not sure what it is. </p>
  
  <ol>
  <li><p>The test example works when I populate specific elements using .add:</p>
  
  <p>-----------EX1-----------</p>
  
  <pre><code>$foo = New-object System.Collections.Arraylist
  
  $foo.add("red")
  
  $foo.add("blue")
  
  $foo.remove("red")
  </code></pre>
  
  <p><code>$foo</code> returns a single element value "blue" (this is good).</p></li>
  <li><p>When I try to populate the array with the results of Get-process (using two different methods below) and try to remove the element value "wssm" it does not seem to be able to find and remove it. </p>
  
  <p>------------EX2--------------</p>
  
  <pre><code>$test = New-object System.Collections.Arraylist(,(get-process |select processname))
  
  $test.Remove("wssm")
  </code></pre>
  
  <p>-------------EX3------------</p>
  
  <pre><code>$test = New-object System.Collections.Arraylist
  
  $test2= get-process |select processname 
  
  $test.Addrange($Test2)
  
  $test.Remove("wssm")
  </code></pre></li>
  </ol>
  
  <p>Examples 2 and 3 do not remove the element containing "wssm" and just returns the whole array list of processnames(wssm is shown as being present in the array) and throws no errors.</p>
  
  <p>When I do a </p>
  
  <pre><code>$foo |get-member
  </code></pre>
  
  <p>It comes back with: </p>
  
  <pre><code>TypeName: System.String
  </code></pre>
  
  <p>And .remove IS listed as a method. When I do a: </p>
  
  <pre><code>$test |get-member
  </code></pre>
  
  <p>It comes back with: </p>
  
  <pre><code>TypeName: Selected.System.Diagnostics.Process
  </code></pre>
  
  <p>And .remove is NOT listed as a method (why this not not throw an error is unknown). </p>
  
  <p>The results of <code>$foo</code> do not contain a header and the results of $test contain a header of "processname" from the select in my get-process step. </p>
  
  <p>Is this a multidimensional array issue and I am just not using the correct syntax in my .remove("wssm") step? Or should I be declaring the array differently?</p>
  
  <p>Thanks for any help.</p>