Forum Discussion
GTM control?
> Get-F5.iControlCommands
Add-F5.LTMPoolMember Add-F5.LTMVirtualServerRule Disable-F5.LTMNodeAddress Disable-F5.LTMPoolMember Disable-F5.LTMVirtualServer Download-F5.Configuration Download-F5.File Enable-F5.LTMNodeAddress Enable-F5.LTMPoolMember Enable-F5.LTMVirtualServer Get-F5.ConfigurationList Get-F5.DBVariable Get-F5.iControl Get-F5.iControlCommands Get-F5.LTMNodeAddress Get-F5.LTMPool Get-F5.LTMPoolMember Get-F5.LTMPoolMemberState Get-F5.LTMRAMCacheEntries Get-F5.LTMRule Get-F5.LTMVirtualServer Get-F5.LTMVirtualServerRule Get-F5.LTMVirtualServerStatistics Get-F5.ProductInformation Get-F5.SystemCPUUsage Get-F5.SystemDiskUsage Get-F5.SystemFanUsage Get-F5.SystemId Get-F5.SystemInformation Get-F5.SystemMemoryUsage Get-F5.SystemPowerUsage Get-F5.SystemTime Get-F5.SystemTimeZone Get-F5.SystemUptime Initialize-F5.iControl Load-F5.Configuration Move-F5.LTMPoolMember New-F5.SharePoint2007Deployment Remove-F5.Configuration Remove-F5.File Remove-F5.LTMPoolMember Remove-F5.LTMRAMCacheEntries Remove-F5.LTMVirtualServerRule Remove-F5.SharePoint2007Deployment Rollback-F5.Configuration Save-F5.Configuration Set-F5.DBVariable Set-F5.LTMPoolMemberState Upload-F5.Configuration Upload-F5.File
I can initialize a connection to the GTM and some of the basic and system commands work fine, but what I would like to use is something like Disable-F5.GTMPoolMember / Enable-F5.GTMPoolMember.
Is there currently a way to do this with the SnapIn? If not, are there any future plans to incorporate GTM commands?
-Ned
10 Replies
- Ned_66277
Nimbostratus
I dug a little bit, and found out this is the function I want to use:
(get-f5.icontrol).GlobalLBPoolMember.set_enabled_state(pool, member/state)
I know what information I need to pass to it, but it apparently wants a particular struct passed to it (MemberEnabledState) that I can’t figure out how to declare:
http://devcentral.f5.com/wiki/default.aspx/iControl/GlobalLB__PoolMember__set_enabled_state.html - Sorry for not posting sooner, I didn't have all my email alerts setup correctly for the new social groups. I wasn't ignoring you - I promise B-).
Good investigation on your part. The Get-F5.iControl cmdlet will return an iControl.Interfaces object that contains members for all of the iControl top-level interfaces. The other cmdlet's were written as utility functions around the main interfaces, but this cmdlet will give you full access to the entire API.
With that said, I'll go ahead and writeup a script and post it later this morning that should get you going. I'll reply to this thread when I'm done.
Again, sorry for the delay...
-Joe - Ned_66277
Nimbostratus
Specifically what I'd like to do is disable a particular GTM pool member in a script (and enable that same member in another script). Something like this (with the correct syntax of course):
(get-f5.icontrol).GlobalLBPoolMember.set_enabled_state("pool_sqlinstance1", "10.1.1.72:0", "STATE_DISABLED")
and
(get-f5.icontrol).GlobalLBPoolMember.set_enabled_state("pool_sqlinstance1", "10.1.1.72:0", "STATE_ENABLED") - As promised, here's a script that will query a GTM's Pools and Pool Members and allow you to get and set the state of the pool members. Let me know if you have any questions:
http://devcentral.f5.com/wiki/default.aspx/iControl/PowerShellGTMPoolMember.html
-Joe - Ned_66277
Nimbostratus
Joe, thank you very much for your reply and code. I tried using this a few different ways but it doesn't want to work for me. Am I calling this incorrectly?
PS G:\PoSH\F5_iControl> ./GTMPoolMember.ps1 gtm1 admin ******* pool_sqlinstance3
Pool 'pool_sqlinstance3' Members
10.1.2.70:0
10.1.100.70:0PS G:\PoSH\F5_iControl> ./GTMPoolMember.ps1 gtm1 admin ******* pool_sqlinstance3 10.1.2.70:0
Cannot convert argument "1", with value: "System.Object[]", for "get_enabled_state" to type "iControl.CommonIPPortDefin
ition[][]": "Cannot convert "System.Object[]" to "iControl.CommonIPPortDefinition[]"."
At G:\PoSH\F5_iControl\GTMPoolMember.ps1:88 char:77
+ $EnabledStateAofA = (Get-F5.iControl).GlobalLBPoolMember.get_enabled_state( <<<< $PoolA, $MembersAofA)
The variable $EnabledStateAofA cannot be retrieved because it has not been set yet.
At G:\PoSH\F5_iControl\GTMPoolMember.ps1:89 char:37
+ $EnabledStateA = $EnabledStateAofA[ <<<< 0];
Pool 'pool_sqlinstance3' member states
The variable $EnabledStateA cannot be retrieved because it has not been set yet.
At G:\PoSH\F5_iControl\GTMPoolMember.ps1:92 char:42
+ foreach($EnabledState in $EnabledStateA) <<<<PS G:\PoSH\F5_iControl> ./GTMPoolMember.ps1 gtm1 admin ******* pool_sqlinstance3 10.1.2.70:0 disable
Exception setting "state": "Cannot convert value "disable" to type "iControl.CommonEnabledState" due to invalid enumeration values. Specify one of the following enumeration values and try again. The possible enumeration values are "STATE_DISABLED, STATE_ENABLED"."
At G:\PoSH\F5_iControl\GTMPoolMember.ps1:114 char:23
+ $MemberEnabledState.s <<<< tate = $State;
Cannot convert argument "1", with value: "System.Object[]", for "set_enabled_state" to type "iControl.GlobalLBPoolMemberMemberEnabledState[][]": "Cannot convert "System.Object[]" to "iControl.GlobalLBPoolMemberMemberEnabledState[]"."
At G:\PoSH\F5_iControl\GTMPoolMember.ps1:117 char:57
+ (Get-F5.iControl).GlobalLBPoolMember.set_enabled_state( <<<< $PoolA, $MemberEnabledStateAofA);
Cannot convert argument "1", with value: "System.Object[]", for "get_enabled_state" to type "iControl.CommonIPPortDefinition[][]": "Cannot convert "System.Object[]" to "iControl.CommonIPPortDefinition[]"."
At G:\PoSH\F5_iControl\GTMPoolMember.ps1:88 char:77
+ $EnabledStateAofA = (Get-F5.iControl).GlobalLBPoolMember.get_enabled_state( <<<< $PoolA, $MembersAofA)
The variable $EnabledStateAofA cannot be retrieved because it has not been set yet.
At G:\PoSH\F5_iControl\GTMPoolMember.ps1:89 char:37
+ $EnabledStateA = $EnabledStateAofA[ <<<< 0];
Pool 'pool_sqlinstance3' member states
The variable $EnabledStateA cannot be retrieved because it has not been set yet.
At G:\PoSH\F5_iControl\GTMPoolMember.ps1:92 char:42
+ foreach($EnabledState in $EnabledStateA) <<<<PS G:\PoSH\F5_iControl> ./GTMPoolMember.ps1 gtm1 admin ******* pool_sqlinstance3 10.1.2.70:0 STATE_DISABLED
Cannot convert argument "1", with value: "System.Object[]", for "set_enabled_state" to type "iControl.GlobalLBPoolMemberMemberEnabledState[][]": "Cannot convert "System.Object[]" to "iControl.GlobalLBPoolMemberMemberEnabledState[]"."
At G:\PoSH\F5_iControl\GTMPoolMember.ps1:117 char:57
+ (Get-F5.iControl).GlobalLBPoolMember.set_enabled_state( <<<< $PoolA, $MemberEnabledStateAofA);
Cannot convert argument "1", with value: "System.Object[]", for "get_enabled_state" to type "iControl.CommonIPPortDefin
ition[][]": "Cannot convert "System.Object[]" to "iControl.CommonIPPortDefinition[]"."
At G:\PoSH\F5_iControl\GTMPoolMember.ps1:88 char:77
+ $EnabledStateAofA = (Get-F5.iControl).GlobalLBPoolMember.get_enabled_state( <<<< $PoolA, $MembersAofA)
The variable $EnabledStateAofA cannot be retrieved because it has not been set yet.
At G:\PoSH\F5_iControl\GTMPoolMember.ps1:89 char:37
+ $EnabledStateA = $EnabledStateAofA[ <<<< 0];
Pool 'pool_sqlinstance3' member states
The variable $EnabledStateA cannot be retrieved because it has not been set yet.
At G:\PoSH\F5_iControl\GTMPoolMember.ps1:92 char:42
+ foreach($EnabledState in $EnabledStateA) <<<< - That is odd. What version of PowerShell are you running? Type in $host.version in the powershell prompt. I'm testing this on v2.0. I just cut and pasted the sample in CodeShare and it worked fine.
This must have something to do with the array conversion from the structure to a 1-d and then a 2-d array. I'll dig in and see what's up with the object conversion into arrays, but that should work the way I did it.
-Joe - Ok, I've updated the script with more explicit type casting on the 1-d and 2-d array creation. Let me know if this works
http://devcentral.f5.com/wiki/default.aspx/iControl/PowerShellGTMPoolMember.html
-Joe - Now at least those make sense. I didn't provide mappings for the friendly states of "enabled" or "disabled". You need to use the true enumeration values of STATE_ENABLED or STATE_DISABLED on your command line.
PS> ./GTMPoolMember.ps1 gtm1 admin ******* pool_sqlinstance3 10.1.2.70:0 STATE_ENABLED
-or-
PS> ./GTMPoolMember.ps1 gtm1 admin ******* pool_sqlinstance3 10.1.2.70:0 STATE_DISABLED
Hopefully this works now. Sorry about the hassle here, I should have provided you with better example usages.
Again, if this doesn't work for you, please let me know.
-Joe - Ned_66277
Nimbostratus
Yes, it works! I am happy, thank you so much for your help! - Araiot_156251
Nimbostratus
Hi to All,
I was looking for examples on the commands but they are blank... so i got to ask how do i use the Save-F5.Configuration command, please provide an example. And what is [-Mode]
Recent Discussions
Related Content
* 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
