You need to access the parentnode if you're variable points at a property-element. Since you need to find a property element where the name is a attribute-value, I prefer using xpath to do this.
$xmlProperties = $file.SelectNodes("/Objects/Object/Property")
Foreach ($xmlProperty in $xmlProperties) {
$strName = ($xmlProperty | Where-Object {$_.Name -eq "IsCoreGroup" }).InnerXml
If ($strName -eq "False")
{
# .. means parent node. So the xpath goes up one level from property, and searches for the new property you want.
$xmlProperty.SelectSingleNode('../Property[@Name="Name"]').InnerXml
}
}
You could also have done $xmlproperty.parentnode.whateveryouwant
.
Personally I'd use xpath to search for the right objects to begin with and retrieve them at object-level, so you can easily access the other properties in the object-node without going up a level.
$file.SelectNodes('/Objects/Object[Property[@Name="IsCoreGroup"]="False"]') | % {
#Foreach object with IsCoreGroup = false, get value of property with Cluster1 as Name attribute
$_.SelectSingleNode('Property[@Name="Cluster"]').innerxml
}
Cluster1