$key="xxxxxxxxx" $secret="xxxxxxxxxx"$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("$($key):$($secret)"))Write-Host $base64AuthInfo
<# This script retrieves the update status of OPNsense, to monitor if the system needs an update.#>$key="xxxxxx" $secret="xxxxxx"$hostname = 'puthostnamehere'<#add-type @" using System.Net; using System.Security.Cryptography.X509Certificates; public class TrustAllCertsPolicy : ICertificatePolicy { public bool CheckValidationResult( ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem) { return true; } }"@[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy#>$user = $key$pass = $secret$pair = "$($user):$($pass)"$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))$basicAuthValue = "Basic $encodedCreds"$Headers = @{ Authorization = $basicAuthValue}$url = "https://$hostname/api/core/firmware/status"Invoke-RestMethod -Uri $url -Method Post -Headers $Headers
$status = $apiResponse.status$statusMsg = $apiResponse.status_msg$newPackages = $apiResponse.new_packages$upgradePackages = $apiResponse.upgrade_packages$reinstallPackages = $apiResponse.reinstall_packages$needsReboot = $apiResponse.needs_reboot
//recent-post[1]/subject
//recent-post[not(contains(subject, 'Re:'))]/subject