I am new to PowerShell and have the following code:
$jsonResponse = @" { "departments":[{"id":81,"department":"Sales"},{"id":61,"department":"IT Support"}] } "@ $myCustomObject = $jsonResponse | ConvertFrom-Json $myCustomObject.departments.department[0] $myCustomObject.departments.department[1]
Lets me access customObject elements (converted from JSON).
I need the ability to scroll an object so that I can access each element i.e.
object_loop { $myCustomObject.departments.department[x] }
where x is the increment of the loop.
Sorry, this is a stupid question, but I have googled and can't find a simple example.
Cheers for any help.
Duncs
source share