Forum Discussion
John_Arnold_106
Nimbostratus
Feb 05, 2008Powershell & Icontrol custom objects
I think I'm not creating a variable correctly, or not referencing a variable correctly. Ideas?
PS Y:\> initialize-icontrol -hostname "testbigip1" -username admin -password testlab
True
PS Y:\> $ic = get-icontrol
Verify icontrol, verify pool membership
PS Y:\> $ic.locallbpool.get_member("pool1")
address port
------- ----
42.0.0.105 80
42.0.0.106 80
42.0.0.107 80
42.0.0.108 80
42.0.0.109 80
42.0.0.110 80
Create poolnames as empty array, add a single string
PS Y:\> $pool_names = @()
PS Y:\> $pool_names += "pool1"
Create a pool member definition
PS Y:\> $member = new-object iControl.CommonIPPortDefinition
PS Y:\> $member.address = "42.0.0.105"
PS Y:\> $member.port = 80
Create a pool member Enabled State definition
PS Y:\> $monitor_state = new-object iControl.CommonEnabledState
PS Y:\> $monitor_state.value__ = 0
Create an array of members and state definitions, associate to previous variables
PS Y:\> $monitor_states = @(new-object iControl.locallbpoolmembermembermonitorstate)
PS Y:\> $monitor_states[0].member = $member
PS Y:\> $monitor_states[0].monitor_state = $monitor_state
Invoke set_monitor_state() with given pool & array
PS Y:\> $ic.locallbpoolmember.set_monitor_state($pool_names,$monitor_states)
Cannot convert argument "1", with value: "System.Object[]", for "set_monitor_state" to type "iControl.LocalLBPoolMemberMemberMonitorState[][]": "Cannot convert "iControl.LocalLBPoolMemberMemberMonitorState" to "iControl.LocalLBPoolMemberMemberMonitorState[]"."
At line:1 char:40
+ $ic.locallbpoolmember.set_monitor_state( <<<< $pool_names,$monitor_states)
PS Y:\>
- John_Arnold_106
Nimbostratus
I figured it out based on someone else's post. Here's the working code...
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