Summary: Use Windows PowerShell remove an item from an array.
How can I remove an item from an array?
Use the ArrayList class, which has the Remove() method (instead of using System.Array,
which does not have this method):
PS > $ArrayList = New-Object System.Collections.ArrayList
PS > [void]$ArrayList.AddRange((1..10))
PS > $ArrayList
1
2
3
4
5
6
7
8
9
10
PS > 1..10 | % {If ($_%2){[void]$ArrayList.Remove($_)}}
PS > $ArrayList
2
4
6
8
10
0 comments