Forum Discussion
ShaneCal_162988
Oct 27, 2016Altocumulus
Based on the answer posted by R Marc, I've created a function in PowerShell that creates pools with new FQDN nodes.
Function Create-Pools
{
<
.SYNOPSIS
Creates a new pool with a new FQDN node
>
[CmdletBinding(HelpURI="https://devcentral.f5.com/questions/possible-to-specify-fqdn-for-new-node-address-via-icontrol-and-powershell")]
param([Parameter(Mandatory=$true)][string]$poolName,
[Parameter(Mandatory=$true)][string]$NodeFqdn,
[Parameter(Mandatory=$true)][string]$port,
[Parameter(Mandatory=$true)][System.Net.WebClient]$webclient,
[Parameter(Mandatory=$true)][string]$F5Host)
$webclient.headers.Add("Content-Type: application/json")
$json='{
"members": [
{
"fqdn": {
"autopopulate": "enabled",
"tmName": "'+$NodeFqdn+'"
},
"name": "'+$NodeFqdn+':'+$port+'",
"priorityGroup": 0
}
],
"name": "'+$poolName+'"
}'
$webclient.UploadString("https://$F5Host/mgmt/tm/ltm/pool","POST",$json)
}
Here's some sample usage:
Construct the webclient object
$webclient = New-Object System.Net.WebClient
$creds = New-Object System.Net.NetworkCredential($username,$password)
$webclient.Credentials = $creds
Create-Pools -poolName "MyPoolName" -NodeFqdn "webserver.test.com" -port 80 -webclient $webclient -F5Host "MyF5Server"