wallst32_178793
May 08, 2015Nimbostratus
How do you call Get-F5.iControl multiple times in PowerShell?
I just started using iControl with PowerShell and haven't had any issues performing a single common task (for example retrieving the list of iRules). But now I'm trying to write some more functional scripts and running into problems when Get-F5.iControl is called a second time. It always returns a $NULL result.
Here is a basic example:
Code
$IC = Get-F5.iControl
Retrieve a specific iRule DataGroupList
$CLASS = $IC.LocalLBClass
$MEMBERS = ($IC.LocalLBClass.Get_String_Class("Test_DG"))
$MEMBERS
Retrieve a list of all iRules
$IRULES = $IC.LocalLBRule.query_all_rules()
$IRULES
If I run the above, it will return the "Test_DG" DataGroupList as an object, but nothing for the iRules.
Now if I simply reverse the order:
Code
$IC = Get-F5.iControl
Retrieve a list of all iRules
$IRULES = $IC.LocalLBRule.query_all_rules()
$IRULES
Retrieve a specific iRule DataGroupList
$CLASS = $IC.LocalLBClass
$MEMBERS = ($IC.LocalLBClass.Get_String_Class("Test_DG"))
$MEMBERS
Now the list of iRules is returned, but the datagroup list is not.
I have also tried "fresh" Get-F5.iControl calls rather than a stored object but the results are the same (for example):
Code
$IRULES = (Get-F5.iControl).LocalLBRule.query_all_rules()
$IRULES
$CLASS = (Get-F5.iControl).LocalLBClass
$MEMBERS = ((Get-F5.iControl).LocalLBClass.Get_String_Class("Test_DG"))
$MEMBERS
Please advise.