Share via

Powershell .length not returning anything

Christopher Jack 1,616 Reputation points
2021-04-08T09:16:36.69+00:00

Hi,

I have the following code which populates an object in Powershell

$products = Invoke-WebRequest -Uri $uri -contentType  "application/json" -Method Get -Headers $headers -UseBasicParsing | ConvertFrom-Json 
$Length = $products.length
$Length 

If I add a breakpoint in after $Length Length is set to null however there are 50 elements in $products. If I pause the code and check $products.length in VS it says 50 however Length is returning null and if I just show $products.length nothing shows up on the screen

Any help appreciated

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments

Answer accepted by question author

Christopher Jack 1,616 Reputation points
2021-04-08T09:20:22.113+00:00

There was another element before length.. issue resolved.

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.