Created
May 27, 2025 18:21
-
-
Save joshooaj/c9d3a6dc186037ad5126b727616c098f to your computer and use it in GitHub Desktop.
Retrieve Milestone Supported Hardware List data
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
function Get-DevicePack { | |
<# | |
.SYNOPSIS | |
Get the device pack from Milestone's online supported hardware list. | |
.DESCRIPTION | |
This command retrieves the device pack data from Milestone's support | |
hardware list available at https://www.milestonesys.com/support/software/supported-devices/xprotect/. | |
The data does not include the detailed information available when clicking | |
on a device in the supported hardware list such as the hardware driver id | |
number. | |
.EXAMPLE | |
PS> $dp = Get-DevicePack | |
PS> $dp | Where-Object { $_.Features.Name -match 'H265' } | |
Find all devices with support for H265. | |
.EXAMPLE | |
PS> $dp = Get-DevicePack | |
PS> $dp | Where-Object DeviceTypeName -eq 'Body worn' | |
Find all supported body worn cameras. | |
#> | |
param () | |
$features = @{} | |
$records = Invoke-RestMethod https://www.milestonesys.com/SupportedHardwareListBlock/LoadFeatures -EA Stop | |
$records | ForEach-Object { | |
$features[$_.Id] = $_ | |
} | |
$records = Invoke-RestMethod https://www.milestonesys.com/SupportedHardwareListBlock/LoadDeviceData?platform=XPCO -EA Stop | |
foreach ($record in $records) { | |
try { | |
if ($null -ne $record.Features -and $record.Features.Count -gt 0) { | |
$record.Features = $record.Features | ForEach-Object { | |
if ($features.ContainsKey($_)) { | |
$features[$_] | |
} | |
} | |
} | |
$record | |
} catch { | |
throw | |
} | |
} | |
} | |
function Get-DeviceDriverId { | |
<# | |
.SYNOPSIS | |
Gets the Hardware Id for a device by scraping the supported device page. | |
.DESCRIPTION | |
This command gets the Hardware Id for a device by scraping the supported | |
device page. The Hardware Id value, also known as the Driver Number, is | |
used by Milestone's API's and the MilestonePSTools module when adding | |
hardware. It specifies which Device Pack driver to use for a device. | |
.PARAMETER DeviceId | |
Specifies the DeviceId value for a supported device. This Id represents a | |
device in the supported hardware list and not a specific device driver. | |
.EXAMPLE | |
$dp = Get-DevicePack | |
$dp | Out-GridView -OutputMode Single | Get-DeviceDriverId | |
.NOTES | |
DDOS-protection will cause an error if you try to use this command to | |
retrieve the driver id for all supported devices in a short period of time. | |
#> | |
param( | |
[Parameter(Mandatory, ValueFromPipelineByPropertyName)] | |
[int]$DeviceId | |
) | |
process { | |
$ErrorActionPreference = 'Stop' | |
$page = Invoke-RestMethod "https://www.milestonesys.com/support/software/supported-devices/supported-device/?deviceId=$DeviceId&platform=XPCO" | |
$options = [text.regularexpressions.regexoptions]::Singleline + [text.regularexpressions.regexoptions]::IgnoreCase | |
$match = [regex]::Match($page, 'Hardware id.+?(?<hwid>\d+)</td>', $options) | |
if ($match.Success) { | |
[int]::Parse($match.Groups['hwid'].Value) | |
} else { | |
Write-Error "Failed to find hardware id for device $DeviceId" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment