Powershell\'s array notation has rather bizarre, albeit documented, behavior for slicing the end of arrays. This section from the official documentation sums up the bizarreness
This could be the most idiomatic way to slice an array with both of its ends:
$array[start..stop] where stop is defined by taking the length of the array minus a value to offset from the end of the array:
$a = 1,2,3,4,5,6,7,8,9
$start = 2
$stop = $a.Length-3
$a[$start..$stop]
This will return 3 4 5 6 7
The start value starts counting with zero, so a start value of '2' gives you the third element of the array. The stop value is calculated with ($a.Length-3), this will drop the last two values because $a.Length-3 itself is included in the slice.
I have defined $start and $stop for clarity, obviously you can also write it like this:
$a = 1,2,3,4,5,6,7,8,9
$a[2..($a.Length-3)]
This will also return 3 4 5 6 7