Last active
August 6, 2025 19:41
-
-
Save davejlong/db4b5331507b5a9a35a089544482418b to your computer and use it in GitHub Desktop.
Probably the worst way to check if the latest version of Huntress is installed on a computer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| PLEASE DO NOT USE THIS | |
| It's parsing the HTML of a blog post to determine the current release version. If you think | |
| this is a safe and secure way to automatically ensure you're running up to date security | |
| software, you should probably rethink your whole security mindset. | |
| #> | |
| iex "$([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('V3JpdGUtT3V0cHV0ICIo4pWvwrDilqHCsO+8ieKVr++4tSDilLvilIHilLsgYG4iCldyaXRlLU91dHB1dCAi0YkowrrQlMK60YkpIGBuIgpXcml0ZS1PdXRwdXQgIkRvbid0IHJ1biBzY3JpcHRzIHlvdSBmaW5kIG9ubGluZSB3aXRob3V0IHJlYWRpbmcgdGhlbS4iClBhdXNlCmV4aXQ=')))" | |
| Import-Module PSParseHtml | |
| function Get-LatestHuntressVersion { | |
| $WindowsVersion = $null | |
| $ReleaseNotes = Invoke-RestMethod -Uri "https://support.huntress.io/hc/en-us/articles/19223729361939-Huntress-Release-Notes-and-Agent-Version" | |
| $Html = $ReleaseNotes | ConvertFrom-Html -Raw | |
| $Sibling = $Html.DocumentNode.SelectNodes("//p") | Where-Object { | |
| $_.InnerText -eq "Current release version" | |
| } | |
| do { | |
| $Sibling = $Sibling.NextSibling | |
| if ($Sibling.InnerText -match "Windows: (?<Version>\d+\.\d+\.\d+)") { | |
| $WindowsVersion = $Matches.Version | |
| } | |
| } while ($null -ne $Sibling -and $null -eq $WindowsVersion) | |
| [Version]$WindowsVersion | |
| } | |
| function Get-InstalledHuntressVersion { | |
| $Health = Invoke-RestMethod -Uri "http://localhost:24799/health" | |
| if ($Health -eq $null) { | |
| Write-Error "Could not retrieve Huntress agent health. Is the agent installed and running?" | |
| } | |
| [Version]$Health.versions.agent | |
| } | |
| $InstalledVersion = Get-InstalledHuntressVersion | |
| $LatestVersion = Get-LatestHuntressVersion | |
| if ($InstalledVersion -lt $LatestVersion) { | |
| Write-Error "Installed version ($InstalledVersion) behind current release ($LatestVersion)" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment