Every now and then, an unconfigured Aerohive AP will pop up in our environment. These access points won’t work until their serial number is enrolled into our HiveManager first.
Finding an unconfigured AP is easy with PowerShell, provided you are using a universal naming convention with existing devices. Because configured APs are named SITE-ROOM-AP01, we can look for DHCP leases that match the default Aerohive AP naming scheme.[note]It is so nice to be able to ping/SSH into an AP without having to look up an IP.[/note]
Here is a script that will look in all DHCP scopes on a server and return any lease that ends with a dash and half a MAC address (ex: AH-0Fa1B3). You will need to change the first two lines to match your environment and you will need the DHCP cmdlets, which are installed with RSAT.
$DHCPServer = 'DHCP-Server-01'
$DOMAIN = 'domain.local'
$Scopes = Get-DhcpServerv4Scope -ComputerName $DHCPServer
foreach ($Scope in $Scopes){
$ScopeID = $Scope.ScopeID
$Leases = Get-DhcpServerv4Lease -ScopeId $ScopeID -ComputerName $DHCPServer | Select-Object HostName,IPaddress,ClientID
$Regex = '([-])([0-9A-Fa-f]{6})(.' + $DOMAIN + ')$'
foreach ($Lease in $Leases){
if ($Lease.HostName -match $Regex -eq $True){
Write-Host $Lease.IPAddress , $Lease.hostname
}
}
}
If you have any problems running this script or improvements to it, just leave a comment!