Last active
August 29, 2015 14:10
-
-
Save desek/bb6483afffbb5c2b3c97 to your computer and use it in GitHub Desktop.
XmlConf Looping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$XmlData = @' | |
<HostGroups> | |
<HostGroup Name="All Hosts"> | |
<HostGroup Name="Oslo"> | |
<LogicalNetworkDefinitions> | |
<LogicalNetworkDefinition name="LM Oslo"> | |
<LogicalNetwork>Live Migration</LogicalNetwork> | |
<Subnet>192.168.5.0/24</Subnet> | |
<VlanID>5</VlanID> | |
</LogicalNetwork> | |
<LogicalNetworkDefinition name="Cluster Oslo"> | |
<LogicalNetwork>Cluster</LogicalNetwork> | |
<Subnet>192.168.10.0/24</Subnet> | |
<VlanID>10</VlanID> | |
</LogicalNetwork> | |
</LogicalNetworks> | |
</HostGroup> | |
<HostGroup Name="Paris" /> | |
<HostGroup Name="Copenhagen" /> | |
</HostGroup> | |
</HostGroups> | |
<LogicalNetworks> | |
<LogicalNetwork Name="Live Migration"> | |
<LogicalNetworkDefinitionIsolation>$false</LogicalNetworkDefinitionIsolation> | |
<EnableNetworkVirtualization>$true</EnableNetworkVirtualization> | |
<UseGRE>$true</UseGRE> | |
<IsPVLAN>$false</IsPVLAN> | |
<VMNetworks> | |
<VMNetwork Name="Live Migration"> | |
<IsolationType>NoIsoloation</<IsolationType> | |
</VMNetwork> | |
</VMNetworks> | |
</LogicalNetwork | |
<LogicalNetwork Name="Cluster"> | |
<LogicalNetworkDefinitionIsolation>$false</LogicalNetworkDefinitionIsolation> | |
<EnableNetworkVirtualization>$false</EnableNetworkVirtualization> | |
<UseGRE>$false</UseGRE> | |
<IsPVLAN>$false</IsPVLAN> | |
<VMNetworks> | |
<VMNetwork Name="Cluster"> | |
<IsolationType>NoIsoloation</<IsolationType> | |
</VMNetwork> | |
</VMNetworks> | |
</LogicalNetwork> | |
</LogicalNetworks> | |
'@ | |
$Xml = [xml]$XmlData | |
Foreach ($HostGroup in $Xml.HostGroups.HostGroup) | |
{ | |
$HostGroup.Name | |
Foreach ($HostGroup in $HostGroup.HostGroup) | |
{ | |
"-- " + $HostGroup.Name | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment