I’m working a lot with GeoServer at the minute and needed to get a start and end date for data available in a layer, I don’t have direct access to the backend so thought I’d have a go at using PowerShell to get what I need. PowerShell 3.0 onward has ConvertFrom-Json and Invoke-WebRequest so it turned out to be rather simple;

$array = @()
$json = Invoke-WebRequest -Uri "" | ConvertFrom-Json
$json.features | ForEach-Object { $array += $ }
$array = $array | Sort-Object
Write-Host "Start: " + $array[0] + ", End: " + $array[$array.Length - 1]

This code creates an empty array, invokes a webrequest to get the JSON from the specified layer, pushes the time property from each feature into the empty array then sorts it. Outputting the first and last element in the array gives start and end.

No doubt there is a max/min function I could have used that I’m not aware of so feel free to mention it in the comments if so. It all turned out to be surprisingly easy and I should be writing a similar block of code in JavaScript soon so will post it as comparison.