Forum Discussion
Mike_Schnorr_64
Nimbostratus
Oct 17, 2007Powershell Twoi-Dimensional Array
I have been using the iControl assembly from PowerShell. Nice work Joe, I look forward to seeing what you come up with for CMDLets.
I am running into a problem with creating multi-dimensional arrays in PowerShell to pass to functions in the iControl assembly. Example, calling LocalLbVirtualServer.Create:
$testActiveF5.LocalLBVirtualServer.create(@($Definition), @($WildMask), @($Resources), $Profile)
What do I need to do to turn the one profile object into a 2-dimensional array?
Thanks
--Mike
- Try adding comma before the variable and surround it by parenthesis.
$testActiveF5.LocalLBVirtualServer.create(@($Definition), @($WildMask), @($Resources), (,$Profile))
- Mike_Schnorr_64
Nimbostratus
No luck. Here is the whole chunk of code I am using as well as the error message in case it helps anyone.$Definition $Definition = New-Object -TypeName icontrol.CommonVirtualServerDefinition $Definition.address = "192.168.1.1" $Definition.name = "IControlTest" $Definition.port = 80 $Definition.protocol = "PROTOCOL_TCP" $WildMask = "255.255.255.255" $Resources = New-Object -typeName iControl.LocalLBVirtualServerVirtualServerResource $Resources.default_pool_name = "TestPool" $Resources.type = "RESOURCE_TYPE_POOL" $Profile = New-Object -typename iControl.LocalLBVirtualServerVirtualServerProfile $Profile.profile_name = "http" $Profile.profile_context = "PROFILE_CONTEXT_TYPE_ALL" $testActiveF5.LocalLBVirtualServer.create(@($Definition), @($WildMask), @($Resources), (,$Profile))
- Mike_Schnorr_64
Nimbostratus
Looks like this works. There is probably a prettier (more PowerShelly) way to do this, but I am going this route for now.$profileArray = new-object "iControl.LocalLBVirtualServerVirtualServerProfile[][]" 1,1 $profileArray[0][0] = $Profile
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