PowerShell Script to Look at Device Data

The end point to look at device (host) data is:

https://api.app.flexerasoftware.com/api/inventory/hosts/ 

To get the Device Data List, use:

GET /api/inventory/hosts/

Below is a sample PowerShell script to look at device data:

$global:WebServiceHeader = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"

$global:WebServiceHeader.Add("Content-Type", 'application/json')

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

$global:WebServiceHeader.Add("Authorization", 'Token YOURTOKENHERE')

$global:WebServiceURLSecunia = "https://api.app.secunia.com/api/"

# Get First Page of results (20 items)

$result = Invoke-RestMethod ($global:WebServiceURLSecunia + "inventory/hosts/") -Method Get -Headers $global:WebServiceHeader

$results = $result.results

#Get the next pages of results, if any

while ($result.next)

{

    $result = Invoke-RestMethod $result.next -Method Get -Headers $global:WebServiceHeader

    $results += $result.results

}

#Simple Dump the data ID then Name

foreach  ($item in $results)

{

    Write-Host $item.id $item.name

}

#Data that you can get from each item

$results[0]