I'm trying to export a list of devices and their parentIDs using the api and PowerShell. I have the lines entered to ignore invalid SSL certs and if I paste the following URL into a web browser, it works fine after clicking SaveAs and providing a path:
https://{host_name}/api/table.xml?content=devices&output=csvtable&columns=device,host,objid,parentid&id=$StartingID&count=20000&username={user_name}&passhash={passhash}
But if I put it in to PowerShell, it does not work:
function getObjGroupList($oHost, $oUser, $oPass) { $url = "https://$oHost/api/table.xml?content=devices&output=csvtable&columns=device,host,objid,parentid&id=$StartingID&count=20000&username=$oUser&passhash=$oPass" $objGroupList = Invoke-WebRequest -Uri $url -MaximumRedirection 0 -ErrorAction Ignore $objGroupList | Export-CSV -Path "{Path}\groupID.csv" -NoTypeInformation }
It creates the CSV file, but it only contains the headers, no data. Has anyone been able to successfully export parentIDs in order to pause and resume probes based on parentID?
Add comment