# Need help to identify which is the active load balancer from PowerShell cmdlets

**URL:** <https://community.f5.com/t/need-help-to-identify-which-is-the-active-load-balancer-from-powershell-cmdlets/7750>\
**Category:** Technical Forums\
**Tags:** icontrol, devops, ltm\
**Created:** [December 28, 2015, 2:00am UTC](https://community.f5.com/t/need-help-to-identify-which-is-the-active-load-balancer-from-powershell-cmdlets/7750 "2015-12-28T02:00:06Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sheela\_Narayan](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@Sheela\_Narayan](https://community.f5.com/u/Sheela_Narayan)\
**Post date:** [December 28, 2015, 2:00am UTC](https://community.f5.com/t/need-help-to-identify-which-is-the-active-load-balancer-from-powershell-cmdlets/7750/1 "2015-12-28T02:00:06Z")

</div>

Need help to identify which is the active load balancer from PowerShell cmdlets and also need to know if can initiate a sync from an active load balancer to passive load balancer using PowerShell.

---

<div class="post-metadata">

**Author:** ![Amit\_Grover\_171](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@Amit\_Grover\_171](https://community.f5.com/u/Amit_Grover_171)\
**Post date:** [December 28, 2015, 3:51am UTC](https://community.f5.com/t/need-help-to-identify-which-is-the-active-load-balancer-from-powershell-cmdlets/7750/2 "2015-12-28T03:51:47Z")

</div>

Hi Sheela,

Not sure about powershell but F5 gives you TMOS shell i.e. TMSH and you can try following.

You can follow below command to check failover details.

```tcl
show sys failover

```

and you can follow below article to sync config.

[Active-standby-sync-using-tmsh-commands](https://devcentral.f5.com/questions/active-standby-sync-using-tmsh-commands)

/Regards Amit Grover

---

<div class="post-metadata">

**Author:** ![Joe\_Pruitt](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/joe_pruitt/32/8438_2.png) [@Joe\_Pruitt](https://community.f5.com/u/Joe_Pruitt)\
**Post date:** [December 29, 2015, 6:57pm UTC](https://community.f5.com/t/need-help-to-identify-which-is-the-active-load-balancer-from-powershell-cmdlets/7750/3 "2015-12-29T18:57:29Z")

</div>

Take a look at the [System.Failover.get\_failover\_state()](https://devcentral.f5.com/wiki/iControl.System __Failover__ get_failover_state.ashx) call. For the device you are making the call on it will return the FailoverState of standby, active, forced offline, offline, or unknown. With PowerShell, you can do something like this (assuming you’ve initialized the snapin already)

```tcl
$ (Get-F5.iControl).SystemFailover.get_failover_state();

```

-Joe

---

<div class="post-metadata">

**Author:** ![Joe\_Pruitt](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/joe_pruitt/32/8438_2.png) [@Joe\_Pruitt](https://community.f5.com/u/Joe_Pruitt)\
**Post date:** [December 29, 2015, 7:01pm UTC](https://community.f5.com/t/need-help-to-identify-which-is-the-active-load-balancer-from-powershell-cmdlets/7750/4 "2015-12-29T19:01:55Z")

</div>

Regarding triggering a config sync from one device to the other, look in the [System.ConfigSync](https://devcentral.f5.com/wiki/iControl.System__ConfigSync.ashx) interface. Look for the synchronize\_\* methods.

---

<div class="post-metadata">

**Author:** ![Sheela\_Narayan](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@Sheela\_Narayan](https://community.f5.com/u/Sheela_Narayan)\
**Post date:** [January 18, 2016, 8:19am UTC](https://community.f5.com/t/need-help-to-identify-which-is-the-active-load-balancer-from-powershell-cmdlets/7750/5 "2016-01-18T08:19:27Z")

</div>

Thanks Amit & Joe

---

<div class="post-metadata">

**Author:** ![Prabu\_MOhan\_102](https://avatars.discourse-cdn.com/v4/letter/p/eb8c5e/32.png) [@Prabu\_MOhan\_102](https://community.f5.com/u/Prabu_MOhan_102)\
**Post date:** [January 18, 2016, 1:52pm UTC](https://community.f5.com/t/need-help-to-identify-which-is-the-active-load-balancer-from-powershell-cmdlets/7750/6 "2016-01-18T13:52:30Z")

</div>

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

```tcl
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.” }

---

<div class="post-metadata">

**Author:** ![Joel\_Newton](https://avatars.discourse-cdn.com/v4/letter/j/c68b51/32.png) [@Joel\_Newton](https://community.f5.com/u/Joel_Newton)\
**Post date:** [January 18, 2016, 2:44pm UTC](https://community.f5.com/t/need-help-to-identify-which-is-the-active-load-balancer-from-powershell-cmdlets/7750/7 "2016-01-18T14:44:39Z")

</div>

This can also be done via the REST API:

```tcl
Create your credential object
$username = "myusername"
$secpasswd = ConvertTo-SecureString "PlainTextPassword" -AsPlainText -Force
$f5device = "mydevicename"
$mycreds = New-Object System.Management.Automation.PSCredential ($username, $secpasswd)

Set the value of the failover page and query it
$FailoverPage = "https://$f5device/mgmt/tm/cm/failover-status"
$FailoverJSON = Invoke-RestMethod -Method Get -Uri $FailoverPage -Credential $mycreds

This is where the failover status is indicated
$FailoverJSON.entries.'https://localhost/mgmt/tm/cm/failover-status/0'.nestedStats.entries.status.description

```

---

<div class="post-metadata">

**Author:** ![Prabu\_MOhan\_102](https://avatars.discourse-cdn.com/v4/letter/p/eb8c5e/32.png) [@Prabu\_MOhan\_102](https://community.f5.com/u/Prabu_MOhan_102)\
**Post date:** [January 18, 2016, 2:52pm UTC](https://community.f5.com/t/need-help-to-identify-which-is-the-active-load-balancer-from-powershell-cmdlets/7750/8 "2016-01-18T14:52:31Z")

</div>

Hi ,

Just realised my last post wasn’t that good :-).. below if the proper one !

```tcl
$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." }

```
