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 rather well:
Negative numbers count from the end of the array. For example, "-1" refers to the last element of the array. To display the last three elements of the array, type:
$a[-3..-1]
However, be cautious when using this notation.
$a[0..-2]
This command does not refer to all the elements of the array, except for the last one. It refers to the first, last, and second-to-last elements in the array.
The following code confirms the bizarreness:
$a = 0,1,2,3
$a[1..-1]
Which indeed outputs this bizarre result:
1
0
3
So, the question is, what is the idiomatic way to slice with one index relative the start and another relative the end of the array?
Please tell me it's something better than this ugly mess:
$a[1..($a.Count-1)]
Edit:
Another way to describe what I'm looking for is this: The idiomatic Powershell equivalent of this python expression:
a=1,2,3,4
a[1:-1]
Which, of course, evaluates to (2,3)