This should be easy, no? I learnt a new method for getting last member of array in PowerShell last week. Up until, I used to get the count of array members, subtract 1 from it (as you know, index starts with 0) and then get that element of array:
PS C:\Users\mgoyal> $newArray = @(“one”,”two”,”three”,”four”,”five”)
PS C:\Users\mgoyal> $lastmember = $newArray[$newArray.Count – 1]
PS C:\Users\mgoyal> $lastmember
In place of above, we can also use this:
PS C:\Users\mgoyal> $newArray[-1]
Not only this, we can also get last 2nd, or 3rd element like that. The idea is that you can use negative index to get elements of array and it starts with -1 and backwards.