cancel
Showing results for 
Search instead for 
Did you mean: 

Powershell script to check AP LAN port speed and duplex

nickzourdos
Contributor

Hello! I was trying to find a way to quickly check if any of my 2,200+ AP's had autonegotiated to 100Mbps, half duplex, etc. but unfortunately this is not possible in the API. The only way to do this is by clicking each AP in SmartZone and scrolling down to the AP details. To save time, I wrote a PowerShell script to do this task. I hope you find it useful. I'm sure it could be improved, I am by no means a PowerShell expert 🙂 

Note: When the login pop-up appears with 'admin' in the user field, ignore it and just press OK. This bypasses the first login prompt when you SSH to an AP. You'll also need to add your SSH credentials to the proper variables, or pass them to the script in your own way. 

 

#If Posh-SSH is not installed on machine, remove comment from line 2
#Install-Module Posh-SSH
Import-Module Posh-SSH

#Build array of AP IP addresses. Read from text file (one IP per line) or type them manually
$ip = Get-Content C:\IP.txt
#$ip = @("10.10.10.10, 10.10.10.11")

#Credentials and command
$credential = Get-Credential -Credential "admin"
$user = "admin"
$pass = "pass"
$command = "get eth"

forEach($x in $ip){
    #Create SSH session quietly, clear output variable
    New-SSHSession -ComputerName $x -Credential $credential -AcceptKey -ErrorAction Stop | Out-Null
    $output = ""

    #Execute commands with delay
    $session = New-SSHShellStream -Index 0
    $session.WriteLine($user.ToString())
    Start-Sleep -Seconds 1

    $session.WriteLine($pass.ToString())
    Start-Sleep -Seconds 1

    $session.WriteLine($command.ToString())
    Start-Sleep -Seconds 1
    $output = $session.Read()
     
    #Report results
    If($output.Contains("Up 1000Mbps full")){
        Write-Host "$x is OK" -ForegroundColor Green
        Remove-SSHSession 0 | Out-Null
        continue
    }elseif($output.Contains("Up 100Mbps full")){
        Write-Host "$x has a 100Mbps port" -ForegroundColor Red 
        "$x has a 100Mbps port" >> C:\APerrors.txt
    }elseIf($output.Contains("Up 10Mbps full")){
        Write-Host "$x has a 10Mbps port" -ForegroundColor Red
         "$x has a 10Mbps port" >> C:\APerrors.txt
    }elseIf($output.Contains("half")){
        Write-Host "$x has HALF DUPLEX" -ForegroundColor Red 
        "$x has HALF DUPLEX" >> C:\APerrors.txt
    }else{Write-Host "$x ERROR" -ForegroundColor Red 
        "$x ERROR" >> C:\APerrors.txt
    } 
    #Disconnect
    Remove-SSHSession 0 | Out-Null
}

 

0 REPLIES 0