Forum Discussion

jnunham_332885's avatar
jnunham_332885
Icon for Altostratus rankAltostratus
Sep 11, 2017

Issue creating multiple nodes with iControl

Hello,

 

I'm trying to add multiple nodes to my F5 LTM from within a PowerShell script. My code works if I manually enter the name of the node and the IP address, but I'm trying to do more than 1 at a time. Below is my code:

 

function Create-Node()

{

param([string]$nameOfNode,
    [string]$nodeIPAddresses,
    [string]$connectionLimits);

$nodes = (, $nameofnode);
$addresses = (, $nodeIPAddresses);
$limits = (, $connectionLimits);

$iControl.LocalLBNodeAddressV2.create(
    $nodes,
    $addresses,
    $limits);

}

Create nodes

$csvPath = "C:\Users\User\Dropbox (Executive)\Documents\Servers.csv"

Import-CSV $csvPath -header ("Server","IPaddress") | foreach {Create-Node -nameOfNode "$_.Server" -nodeIPAddresses "$_.IPaddress" -connectionLimits "0"}

When I run the script, I get the following error messages:

 

Exception calling "create" with "3" argument(s): "Exception caught in LocalLB::urn:iControl:LocalLB/NodeAddressV2::create() Common::InvalidArgument " At C:\Users\User\Dropbox (Executive)\Desktop\F5_Config_DEV.ps1:142 char:1 + $iControl.LocalLBNodeAddressV2.create( + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : SoapHeaderException

 

Can someone help me figure out what I'm doing wrong? I really would like a way to create multiple nodes at once instead of having a single line to create each node.

 

Thanks!

 

  • Hello, Based on test, I think you just need to remove double quotes to expand variable on param object.

    Import-CSV $csvPath -header ("Server","IPaddress") | foreach { Create-Node -nameOfNode $_.Server -nodeIPAddresses $_.IPaddress -connectionLimits 0 }

    In addition, I think you could simplify the function.

    function Create-Node() {
    param([string]$nameOfNode,
        [string]$nodeIPAddresses,
        [long]$connectionLimits);
    
        $iControl.LocalLBNodeAddressV2.create( @($nameOfNode), @($nodeIPAddresses), @($connectionLimits) );
    }
    

    Respectfully,