Forum Discussion
Jake_46670
Nimbostratus
Jun 04, 2009Working with Datagroup members in Powershell
I'm run into a bit of an issue when attempting to work with members of a Datagroup via powershell. So far I have:
If ( (Get-PSSnapin | Where-Object { $_.Name -eq "iControlSnapIn"}) -eq $null )
{
Add-PSSnapIn iControlSnapIn
}
$LBConRC = Initialize-F5.iControl -Hostname $LBAddress -Username $LBUsername -Password $LBPassword
$LBClass = (Get-F5.iControl).LocalLBClass
$colOldVer = $LBClass.get_string_class((,"POD_Org_Old_Version"))
I know my datagroup "POD_Org_Old_version" contains a couple of strings, i've verified this by:
$colOldVer
I see the strings as expected but from that point... how can I, for example, check if the string "Engineer_Not_Developer" is in the datagroup? I've tried:
if ($colOldVer -contains "Engineer_Not_Developer") {...
Without luck... I also tried a foreach...
Thanks for the help!
Jason
- Sorry for the delay in the response, somehow this slipped on my radar.
class StringClass { String name; String [] members; }; StringClass [] get_string_class( in String [] class_names );
$classList = $LBClass.get_string_class((,"POD_Org_Old_Version")); $class = $classList[0]; $matches = $class.Members | Where-Object { $_ -eq "Engineer_Not_Developer" } if ( $matches ) { Write-Host "Found match!" } else { Write-Host "Didn't find match" }
$classList = $LBClass.get_string_class((,"POD_Org_Old_Version")); if ( $classList[0].Members | Where-Object { $_ -eq "Engineer_Not_Developer" } ) { Write-Host "Found match!" } else { Write-Host "Didn't find match" }
$classList = $LBClass.get_string_class((,"POD_Org_Old_Version")); foreach ($member in $classList[0].Members ) { if ( $member -eq "Engineer_Not_Developer" } { Write-Host "Found match!" } else { Write-Host "Didn't find match" } }
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