XML Help

Guys,

Using ADSI I have a variable containg my domains. I can easily access the domainname using $domain.properties.dnsroot format.

What I want to do is use this information to populate a drop-down list. I thought I’d use convertto-xml and then bind the drop-down. Issue is, I do not know how to access the domainname from this xml variable/document.

The convertto-xml produces something similar to


<?xml version="1.0"?>
<Objects>
<Object>
<Property Name="Path">LDAP://something1</Property>
<Property Name="Properties">
<Property Name="Key">dnsroot</Property>
<Property Name="Value">
<Property>domain1</Property>
</Property>
<Property Name="Key">adspath</Property>
<Property Name="Value">
<Property>LDAP://something2</Property>
</Property>
</Property>
</Object>
<Object>
<Property Name="Path">LDAP://something3</Property>
<Property Name="Properties">
<Property Name="Key">dnsroot</Property>
<Property Name="Value">
<Property>domain2</Property>
</Property>
<Property Name="Key">adspath</Property>
<Property Name="Value">
<Property>LDAP://something4</Property>
</Property>
</Property>
</Object>
<Object>
<Property Name="Path">LDAP://something5</Property>
<Property Name="Properties">
<Property Name="Key">dnsroot</Property>
<Property Name="Value">
<Property>domain3</Property>
</Property>
<Property Name="Key">adspath</Property>
<Property Name="Value">
<Property>LDAP://something6</Property>
</Property>
</Property>
</Object>
</Objects>

Any idea on how I can access domain1, domain2 and domain3 from the above file ? Or is there a better way ?

Thanks in advance.

I wouldn’t convert to XML. Just do something like this:

$domainNames = @($domains | ForEach-Object {$_.properties.dnsroot})