Forum Discussion
Jeff_Robertson
Nimbostratus
Jun 06, 2014Powershell Pool creation only adding 1 node
Hoping someone can help me out with some powershell sytax for creating F5 Pools This is what I have, it is part of a deployment script that builds 50+ servers. This is what I was able to piece togeth...
Jun 06, 2014
Hi
Seems like you've got some mixup with the array dimensions:
$MemberDefAofA[0][0] = $MemberDef
Adding it to an array
$Members += $MemberDefAofA
would create a tri-dimensional array, I guess.
Try something like this (had to rewrite it since I did not know how you declared the previous variables in your script):
Initialize Snapin
if ( (Get-PSSnapin | Where-Object { $_.Name -eq "iControlSnapIn"}) -eq $null ){
Add-PSSnapIn iControlSnapIn
}
$User = "iUser"
$Password = "mypassword"
$Partition = "Common"
$BigIP = "192.168.161.10"
Declare variables
$ObjMembers = @()
$NodeDict = @{}
Connect to the BigIP
$Success = Initialize-F5.iControl -HostName $BigIP -Username $User -Password $Password
Get an iControl Handle
$F5 = Get-F5.iControl
$PoolMembers = ("192.168.20.1", "192.168.20.2")
$PoolName = "PSPool"
$Members = @()
$LBMethod = "LB_METHOD_LEAST_CONNECTION_MEMBER"
$MonitorName = "https"
$MemberDefAofA = New-Object -TypeName "iControl.CommonAddressPort[]" 2
$MemberDef = New-Object -TypeName iControl.CommonAddressPort
$MemberDef.address = "PajoIIS"
$MemberDef.port = 8011
$MemberDefAofA[0] = $MemberDef
$MemberDef = New-Object -TypeName iControl.CommonAddressPort
$MemberDef.address = "PajoIIS"
$MemberDef.port = 8012
$MemberDefAofA[1] = $MemberDef
(Get-F5.iControl).LocalLBPool.Create_v2((,$PoolName), (,$LBMethod), (,$MemberDefAofA))
Just a comment. The create_v2 method would technically expect the pool name and load balancing methods to be arrays too. It accepts it, but it's... "prettier" to it that way. 🙂
/Patrik
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects