iControl is an inbuilt API to F5 devices which can be used to view and make configuration changes. Most of the documentation is for LTMs (Local Traffic Manager) but the PowerShell script below will use iControl on a GTM (Gloabl Traffic Manager) to loop through all pool members and see if any are disabled, if any are disabled it will send an email stating which members are disabled.

To run this script you must first have the iControl PowerShell Script Snapin installed.

It can be installed from this link below:

https://devcentral.f5.com/Community/GroupDetails/tabid/1082223/asg/3/aff/2107/showtab/groupforums/Default.aspx

#---------define Functions----------

###############################################################
# GetPools() #
# Gets an array of pools from the GTM.
# The F5 must be initialized before calling this script. #
# $return string[]
###############################################################

function GetPools() {
	$list = (Get-F5.iControl).GlobalLBPool.get_list();
	return $list;
}

###############################################################
# GetMembers() #
# Gets the Members in the Pool provided and returns an Array of Members #
# @param string $Pool Name of the Pool to get Members
# @return iControl.CommonIPPortDefinition[] #
###############################################################

function GetMembers() {
	param([string]$Pool);
	$Members = (get-f5.icontrol).GlobalLBPool.get_member((,$Pool));

	$MemberA = $Members[0]; return $MemberA;
}

###############################################################
# GetMemberState() #
# Pass in a member. Then it receives the state of that member. #
# @param iControl.CommonIPPortDefinition[] Member, string Pool
# @return string #
###############################################################

function GetMemberState() {
param([iControl.CommonIPPortDefinition[]]$Member, [string]$Pool);

	$PoolA = (, $Pool); #Set Pool [iControl.CommonIPPortDefinition[][]]
	$MemberAofA = [iControl.CommonIPPortDefinition[][]](, $Member); #Set Object F5 is expecting
	$EnabledStateAofA = (Get-F5.iControl).GlobalLBPoolMember.get_enabled_state($PoolA, $MemberAofA)
	$EnabledStateA = $EnabledStateAofA[0]; #Get first object value

	foreach($EnabledState in $EnabledStateA) {
		$state = $EnabledState.state; #loop through Memers and get State
	}
	return [string]$state #return the state of the member passed in
}

#-----------Main Application-------------

$SnapinSet = Get-PSSnapin | select-string -Quiet -Pattern "iControlSnapin"

if(!$SnapinSet) { #check to see iControlSnapin has been added
	#if it hasn't been added then add it
	Add-PSSnapin iControlSnapin
}

#attempt to initilize connection to the correct IP
if(Initialize-f5.icontrol -hostname 1.1.1.1 -Username username -password password) {
	start-transcript -Path "Log.txt" -Append -Force #log output

	$Pools = GetPools

	$DisabledState = $FALSE
          $DisabledNodes = @()

	foreach($Pool in $Pools) #loop through pools {
		$Pool = [string]$Pool

		$Members = GetMembers -Pool $Pool

		#loop through members in a pool
		foreach($Mem in $Members) {
			$addr = $Mem.member.address;
			$port = $Mem.member.port;

			$MemberDef = New-Object -TypeName iControl.CommonIPPortDefinition;
			#set object
			$MemberDef.address = $addr
			$MemberDef.port = $port
			[iControl.CommonIPPortDefinition[]]$MembersA = [iControl.CommonIPPortDefinition[]](, $MemberDef)
			$state = GetMemberState -Member $MembersA -Pool $Pool
			#get state of the member
			if($state -eq "STATE_DISABLED") {
				#if member is disabled add it to the output to send in an email
				$Node = "${addr}:${port}"
				$DisabledNodes += "$Pool -> $Node"
				$DisabledState = $TRUE
			}
		}
	}

	if($DisabledState) {
		#if a disabled member has been found
		$Content = "The following nodes are disabled:"
		write-host "the following are disabled"

		foreach($Node in $DisabledNodes) {
			write-host $Node $Content += "$Node " #create html content to send in an email
		}

		#send email
		Send-MailMessage -To "<a href="mailto:to@example.com">to@example.com</a>" -From "<a href="mailto:from@example.com">from@example.com</a>" -subject "Nodes Disabled In GTM" -body "$Content" -bodyashtml -smtpServer 1.1.1.1

	}
	stop-transcript #stop logging
}
else {
	write-host "Critical Error Has Occurred. Cannot Initialize iControl" #if connection to F5 fails produce error
}