Public/Get-UnifiWlan.ps1
|
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 } |