Reputation: 1574
I have json that I get from an API that returns a value like this
[{
"Location": "/xxx/005D2"
}, {
"Location": "/xxx/020D2"
}, {
"Location": "/xxx/061D2"
}, {
"Location": "/xxx/086D2"
}, {
"Location": "/xxx/100D2"
}]
When I call the URL and access the variable
$installs= Invoke-RestMethod -Uri $installLocation -Method Get;
I get the following
Location
--------------
/xxx/100D2
/xxx/120D2
/xxx/110D2
etc
How can I loop through these so I only access 1 location at a time?
Upvotes: 1
Views: 1031
Reputation: 3154
You acutally don't want to loop through JSON, but through a PowerShell object ($installs
). You can do that, as with any other PowerShell object.
$installs | ForEach-Object {
$_.Location
}
Upvotes: 2