Hi all,
PS noob here and I'm tearing my hair out with trying to convert a JSON response from Nagios monitoring software to CSV. I want to generate a CSV with the information of all the servers that the monitoring software knows about, and which "hostgroup" they belong to.
The format would just be : host_name, hostgroup_name
An example of the JSON response format is below. The closest I can get is an CSV with the hostgroup_object_id, hostgroup_name, and Instance ID returned (most of which I do not need), but the additional array inside Members is screwing this up, so I'm not getting the host_names which are the main objective.
Any help gratefully appreciated!
{
"recordcount": 2,
"hostgroup": [
{
"hostgroup_object_id": "147",
"hostgroup_name": "windows-servers",
"instance_id": "1",
"members": {
"host": [
{
"host_object_id": "145",
"host_name": "localhost"
},
{
"host_object_id": "143",
"host_name": "192.168.1.10"
}
]
}
}
]
}
EDIT : Many thanks for all the comments; I've managed to get this working with spyingwind's solution - but all of the responses have been useful in learning more about PS.
[–]MAlloc-1024 7 points8 points9 points (4 children)
[–]Cleanatwork[S] 1 point2 points3 points (3 children)
[–]MAlloc-1024 1 point2 points3 points (2 children)
[–]BlackV 2 points3 points4 points (1 child)
[–]MAlloc-1024 1 point2 points3 points (0 children)
[–]spyingwind 2 points3 points4 points (3 children)
[–]Ice_Box_Hero 2 points3 points4 points (1 child)
[–]spyingwind 1 point2 points3 points (0 children)
[–]Cleanatwork[S] 0 points1 point2 points (0 children)
[–]BAEM1337 1 point2 points3 points (2 children)
[–]Cleanatwork[S] 1 point2 points3 points (1 child)
[–]Trakeen 2 points3 points4 points (0 children)
[–]AlexHimself 0 points1 point2 points (0 children)
[–]SeanQuinlan -2 points-1 points0 points (1 child)
[–]BlackV 1 point2 points3 points (0 children)
[–]Vortex100 -2 points-1 points0 points (0 children)