Created
January 28, 2021 10:12
-
-
Save hdurdle/d1070aa467c04da40b83c8c682755ff8 to your computer and use it in GitHub Desktop.
Get UniFi Client Stations from a UDM Pro
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
# config | |
$unifiServerURI = "https://192.168.1.1" # https://192.168.1.1 | |
$unifiUsername = "unifi-login-email" | |
$unifiPassword = "unifi-login-password" | |
# # # | |
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true } | |
$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12' | |
[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols | |
$baseURI = "$unifiServerURI/api" | |
$loginURI = "$baseURI/auth/login" | |
$statusURI = "$unifiServerURI/proxy/network/api/s/default/stat/sta" | |
$cred = "`{`"username`":`"$unifiUsername`",`"password`":`"$unifiPassword`"`}" | |
# Perform login and get session for token | |
Invoke-RestMethod -uri $loginURI -Method Post -Body $cred -ContentType "application/json" -SessionVariable session | out-null | |
# Use session to get /sta (client stations) list | |
$response = Invoke-RestMethod -Uri $statusURI -Method Get -WebSession $session | |
$response.data | |
# Query to find stations where current and fixed IP are different | |
#| where-object {$_.fixed_ip -and $_.ip -ne $_.fixed_ip} |select hostname,name,ip,fixed_ip, is_wired | Sort-Object ip |ft |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment