Forum Discussion

naydencho_66052's avatar
naydencho_66052
Icon for Nimbostratus rankNimbostratus
Dec 13, 2011

Adding a pool member syntax

Hello

I am trying to add a node to a pool (with PowerShell) using the following syntax:

 

 

 

(Get-F5.iControl).LocalLBPool.add_member("pool_test", "10.3.5.92:80")

 

 

 

The error I get is

 

Cannot convert argument "1", with value: "10.3.5.92:80", for "add_member" to type "iControl.CommonIPPortDefinition[][]"

 

: "Cannot convert the "10.3.5.92:80" value of type "System.String" to type "iControl.CommonIPPortDefinition[][]"."

 

At line:1 char:41

 

+ (Get-F5.iControl).LocalLBPool.add_member <<<< ("pool_test", "10.3.5.92:80")

 

+ CategoryInfo : NotSpecified: (:) [], MethodException

 

+ FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument

 

 

 

 

 

 

What is the correct syntax for the second parameter? I can't seem to find it in the forums, wiki, API documentation... :(

 

 

 

Thanks in advance!

 

 

 

3 Replies

  • In your code, you are just passing in a scalar string for both the pool_name and members parameters. The definition for the function is:

    add_member (

    String [] pool_names,

    Common__IPPortDefinition [][] members

    );

    The first parameter is an array of strings, one for each pool you want to add members to. The second parameters is a 2-d array, with each dimension for the list of members you want to add to the given pools in the first parameter.

    I'm not at my desk right now, so I don't have an exact code snippet for that function in PowerShell, but I did put this up in the codeshare a while ago where it uses the PoolMember.get_statistics() method

    http://devcentral.f5.com/wiki/iControl.PsPoolMemberControl.ashx

    Look down in the Disable-Member function for the call to get_statistics. In that call, I pass in a single pool in the pool_name variable, and a single member for the second param. The return value isn't the same for the two methods, but it should show you how to declare the proper types for the parameters and how to fill them in.

    Hope this helps...

    -Joe

  • That was perfect, thank you! The code is basically the same, I just did not realize I have to create the iControl.CommonIPPortDefinition objects... :) n00b :)

     

     

    Thanks again!