Initial commit. Working and linked on PSGallery

This commit is contained in:
2026-05-15 08:53:21 +08:00
commit 7c77363885
17 changed files with 1109 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
function Get-UnifiDevice {
[CmdletBinding()]
param(
[string]$Site
)
if (-not $script:UnifiSession) {
Write-Error "Not connected. Run Connect-UnifiController first."
return
}
$siteId = Resolve-UnifiSite $Site
$result = Invoke-UnifiRequest -Endpoint '/stat/device' -Site $siteId
if (-not $result.data -or $result.data.Count -eq 0) {
Write-Warning "No devices found on site '$siteId'."
return
}
$result.data | Select-Object `
@{ N = 'Name'; E = { if ($_.name) { $_.name } else { $_.mac } } },
@{ N = 'Type'; E = { switch ($_.type) {
'uap' { 'Access Point' }
'usw' { 'Switch' }
'ugw' { 'Gateway' }
'udm' { 'Dream Machine'}
default { $_.type }
} } },
@{ N = 'Model'; E = { $_.model } },
@{ N = 'IP'; E = { $_.ip } },
@{ N = 'MAC'; E = { $_.mac } },
@{ N = 'State'; E = { switch ($_.state) {
0 { 'Disconnected' }
1 { 'Connected' }
2 { 'Pending' }
4 { 'Upgrading' }
5 { 'Provisioning' }
default { "State $($_.state)" }
} } },
@{ N = 'Version'; E = { $_.version } }
}