Remove First Entry in Fixed Array

Here is a quick little trick for removing the first entry in a fixed size array. This can be used when you receive the error message: Exception calling “RemoveAt” with “1” argument(s): “Collection was of a fixed size.”

# Remove first entry
$array = $array[1..($array.Length-1)]


Example

PS C:\> $array = 1..5
>> Write-Host 'Initial Value'
>> $array
>> $array = $array[1..($array.Length-1)]
>> Write-Host 'After Value'
>> $array

Initial Value
1
2
3
4
5
After Value
2
3
4
5