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

49
Public/Get-UnifiWlan.ps1 Normal file
View File

@@ -0,0 +1,49 @@
function Get-UnifiWlan {
[CmdletBinding()]
param(
[string]$Site,
# Filter by SSID name
[string]$Ssid,
# Include the passphrase in output — omitted by default
[switch]$ShowPassword
)
if (-not $script:UnifiSession) {
Write-Error "Not connected. Run Connect-UnifiController first."
return
}
$siteId = Resolve-UnifiSite $Site
$result = Invoke-UnifiRequest -Endpoint '/rest/wlanconf' -Site $siteId
if (-not $result.data -or $result.data.Count -eq 0) {
Write-Warning "No WLANs found on site '$siteId'."
return
}
$wlans = $result.data
if ($Ssid) {
$wlans = $wlans | Where-Object { $_.name -eq $Ssid }
if (-not $wlans) {
Write-Warning "No WLAN named '$Ssid' found on site '$siteId'."
return
}
}
$props = [System.Collections.Generic.List[object]]@(
@{ N = 'SSID'; E = { $_.name } }
@{ N = 'Enabled'; E = { $_.enabled } }
@{ N = 'Security'; E = { $_.security } }
@{ N = 'Band'; E = { switch ($_.wlan_band) { '2g' {'2.4 GHz'} '5g' {'5 GHz'} 'both' {'Both'} default { $_.wlan_band } } } }
)
if ($ShowPassword) {
$props.Add(@{ N = 'Password'; E = { $_.x_passphrase } })
}
$props.Add(@{ N = 'ID'; E = { $_._id } })
$wlans | Select-Object $props
}