Are you certain that $snaplist contains valid data? Depending on what value $ArrayIP has, I see a potential error. If it's simply the IP/hostname of the array as I expect it might be, then I suggest that you change this line:
$uri = "https://" + $ArrayIP + "snapshot_collections/detail"
to instead be
$uri = "https://" + $ArrayIP + ":5392/v1/snapshot_collections/detail"
Otherwise, when you invoke the API in the following line, you are likely to get an error. The only other thing that jumps out is that I don't know what $ProdVolumeCollection looks like here. If it's invalid, then $ProdVolume_array would wind up being empty.
Not sure about the snapshot_collections failure, but the snapshots object failed with this error:
Invoke-RestMethod : The remote server returned an error: (400) Bad Request.
snapshots objectset does not support listing all objects. The complete response for this error would be some thing like this:
"text":"The request could not be understood by the server."
"text":"Missing the argument 'vol_id' in the request."
You will have to provide the id of a particular volume to list the snapshots. For e.g. you can use a query URL like this:
I may have found the problem:
$ProdVolume_array = $prod_array | select snapshots_list, name, creation_time |where-object name -like $ProdVolumeCollection* | sort-object -Property creation_time -descending
$ProdVolume_array = $prod_array | select * |where-object volcoll_name -eq $ProdVolumeCollection | sort-object -Property creation_time -descending
In some local testing this appears to take care of the issue, but I need to validate.
I'm still not sure why it all of the sudden failed.