Where-object cmdlet does not seem to behave as expected and returns error
Got an interesting one for you. Consider this line of powershell code: $networks = Invoke-RestMethod -Uri "$baseurl/organizations/$orgid/networks" -Method get -Headers $headers | where-object {$_.name.Substring($_.name.length - 5) -in $csv.'Store No.'} The idea is to compare only the last 5 characters in the “name” property returned by the invoke-restmethod cmdlet to the values contained in another collection. The code looks solid to me, but when I run it, I get this: Exception calling "Substring" with "1" argument(s): "startIndex cannot be larger than length of string. Parameter name: startIn
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.