Forum Discussion
Need help to identify which is the active load balancer from PowerShell cmdlets
This should help identify active standby:-) $Hostname1="F5 Device ip" $Hostname2="F5 Device ip" $Username="Username" $Password="password"
Check and load icontrol Snapin$checkSnapIn = Get-PSSnapIn iControlSnapIn -EA SilentlyContinue If ($checkSnapIn.length -eq 0) { Add-PSSnapIn iControlSnapIn }
Login and Unit Active \Standby check$login = Initialize-F5.iControl -HostName $Hostname1 -Username $Username -Password $Password
if ($login -eq "true") { Write-Host Logged into $Hostname1 F5 successfully.; $ISactive = Get-F5.DBVariable -Name Failover.State | select Value | ft -hide |Out-String
if ( $ISactive.trim() -eq "active")
{
Write-Host "Device" $Hostname1 is $ISactive.trim();
} else {
$login = Initialize-F5.iControl -HostName $Hostname2 -Username $Username -Password $Password
if ($login -eq "true")
{
Write-Host Logged into $Hostname2 F5 successfully.;
$ISactive = Get-F5.DBVariable -Name Failover.State | select Value | ft -hide |Out-String
Write-Host "Device" $Hostname2 is $ISactive.trim();
if ( $ISactive.trim() -ne "active"){
Write-Host "Something went wrong both servers are not set active";
}
}else{
Write-Host "Login in Failed."
}
}
}else { Write-Host "Login in Failed." }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com