Pool's are collections of pool members which are IP address and ports for a specific back end application server.  Currently through the iControl API there is no direct way to do a reverse lookup of which pools a specified application server is a member of.  This application will, given a pool member specification, do a reverse lookup and list all the associated pools that member is included in.


The arguments for this application are the address, username, password of the BIG-IP as well as an optional wildcard spec for the address:port of the requested Pool Member.  This is declared in the top of the script with the following param statement.  There is also a Write-Usage function to display the arguments to the user.

param ( $bigip = $null, $user = $null, $pass = $null, $poolmember = $null ); 
Set-PSDebug -strict; 
# function Write-Usage 
function Write-Usage() {
  Write-Host "Usage: PoolLookup.ps1 host uid pwd [poolmember]"; 


As is with all of my PowerShell scripts, the initialization component will look to see if the iControlSnapIn is loaded into the current PowerShell session.  If not, the Add-PSSnapIn Cmdlet is called to add the snapin into the runtime.  Then a call to the Initialize-F5.iControl cmdlet to setup the connection to the BIG-IP.  If this succeeds, then a call to the Lookup-Pool function is called to lookup the pools containing the requested member address:port combination.

function Do-Initialize() { 
  if ( (Get-PSSnapin | Where-Object { $_.Name -eq "iControlSnapIn"}) -eq $null ) { 
    Add-PSSnapIn iControlSnapIn
  $success = Initialize-F5.iControl -HostName $bigip -Username $user -Password $pass; 
  return $success; 
# Main Application Logic 
if ( ($bigip -eq $null) -or ($user -eq $null) -or ($pass -eq $null) ) { 
if ( Do-Initialize ) { 
  if ( $poolmember ) { 
    Lookup-Pool $poolmember; 
  } else { 
} else { 
  Write-Error "ERROR: iControl subsystem not initialized" 

Querying Pool Names and Members

The Lookup-Pool function takes an optional argument containing the virtual server address:port query.  If a query is specified, it will attempt to be split apart with a colon separator.

Once the query is disassembled, the Pool list is retrieved as well as the associated pool members.  For each of the pool members , a comparison is done to determine if the input query is a match.  If no query is supplied, the entry is displayed.

The Write-Match then is called to print a spaced formatted output for the results

function Lookup-Pool() { 
  param([string]$query = $null); 
  $addr = "*"; $port = "*"; 
  if ( $query ) { 
    $addr = $query; $tokens = $query.Split(':'); 
    if ( $tokens.Length -eq 2 ) { 
      $addr = $tokens[0];
      $port = $tokens[1]; 
    if ( !$addr ) { $addr = "*"; } 
    if ( !$port ) { $port = "*"; } 
  $pool_list = (Get-F5.iControl).LocalLBPool.get_list(); 
  $member_lists = (Get-F5.iControl).LocalLBPool.get_member($pool_list); 
  for($i=0; $i-lt$pool_list.Length; $i++) { 
    $pool = $pool_list[$i]; 
    $member_list = $member_lists[$i]; 
    for($j=0; $j-lt$member_list.Length; $j++) { 
      $maddr = $member_list[$j].address; 
      $mport = $member_list[$j].port; 
      if ( !($query) -or ("${maddr}:${mport}" -like "${addr}:${port}") ) { 
        Write-Match -pool $pool -address $maddr -port $mport; 
function Write-Match() { 
  param( [string]$pool = $null, [string]$address = $null, [int]$port = $null ); 
  if ( $pool -and $address -and $port ) { 
    $obj = 1 | select PoolMember, Pool 
    $obj.PoolMember = "${address}:${port}";
    $obj.Pool = $pool; $obj; 

Running The Code

With no query specified, a list of all pool members is displayed along with their associated pools.  Note that pool members may be displayed twice if they belong to more than one pool.  The next few executions pass various wildcard options for th e the ip address and/or port and shows the resulting displays.

 PS> .\PoolLookup.ps1 bigip user pass PoolMember Pool 
---------- ---- xpbert-ssh xpbert-http xpbert-http pool_2 pool_1 pool_1 dc-sea-web dc-sea-web dc-sea-media dc-llix-web dc-llix-web dc-llix-media catbert-ssh catbert-http 
PS> .\PoolLookup.ps1 bigip user pass *:22 PoolMember Pool 
---------- ---- xpbert-ssh catbert-ssh 
PS .\PoolLookup.ps1 bigip user pass *.149:8* PoolMember Pool 
---------- ---- xpbert-http xpbert-http pool_1


This script shows the steps on how to do a reverse wildcard lookup for virtual server names that have a destination address matching a specified search criteria.  Similar logic could be performed to do reverse lookups for pool members or node addresses.

Sample Walkthrough

The full source for this application can be found in the iControl Codeshare under PsPoolLookup.