PowerShell Script to List All Devices and Their System Scores
Below is a sample PowerShell script to list all devices and their system scores:
$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 -ForegroundColor Yellow -NoNewline
Write-Host " " $item.name -ForegroundColor White -NoNewline
Write-Host " " $item.stat.system_score -ForegroundColor Green
}
Below is the sample output: