PowerShell Script to Look at Product Data

The end point to look at product data is:

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

To get the product data list, use the following:

GET /api/inventory/products/

Below is a sample PowerShell script to look at product 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/products/") -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.product.name "Installed" $item.stat.hosts "Insecure" $item.stat.insecure_hosts

}

#Data that you can get from each item

$result.results[0]