Forum Discussion

Jeff_Brinkerho1's avatar
Jeff_Brinkerho1
Icon for Nimbostratus rankNimbostratus
Sep 08, 2016

Powershell iControl Snapin - DISconnecting from one LTM, connecting to another - same script

We have a need to populate an address datagroup from an external database. I currently have a working proof of concept in powershell using the F5 supplied iControl snapin. Works great.

However, we have a pair of LTM4000's - running active/standby. I want to cover the case where a standby swap has happened and the active is now standby.

I have noticed that when I connect to the LTM using

Initialize-F5.iControl
that I cannot "disconnect", and that if I try to connec to to the second LTM using a second statement (with a different hostname), that all subsequent commands pull information from the FIRST connected LTM.

For example,

(Get-F5.iControl).ManagementDBVariable.query("hostname")
will show the hostname of the first one I initialize no matter what.

I'm new to powershell, and I must be missing something here. If anyone can lend a hand - the problem I'm trying to solve is:

Connect to both LTM's, and determine which is active Connect to only that LTM and perform our manipulation of the address data group.

Each loop through I would check and connect to only the active. Probably would also be nice to check the sync state, just in case it winds up in an inconsistent state I can abort/error. I suspect that perhaps I need to set a hostname value for each icontrol command to tell it where to go?

Thanks in advance

1 Reply

  • All the initialize call does is to validate the credentials and then store them for use when accessing any of the other modules within that class. You can call Initialize again with the new values. Another option is to just allocate an iControl interfaces object for each destination and use that.

    $ic1 = New-Object -TypeName iControl.Interfaces
    $ic1.initialize(bigip1, user, pass)
    
    $ic2 = New-Object -TypeName iControl.Interfaces
    $ic2.initialize(bigip2, user, pass)
    
    $ic1.LocalLBPool.get_list();
    $ic2.LocalLBPool.get_list();
    

    Hope this helps...

    -Joe