HI i'm new to Powershell and i'm trying to read an xml file with some conditions, here is the file
<file>
<userlist>
<user name="Martin" log="[email protected]"></user>
<user name="Tec" log="[email protected]"></user>
<user name="Obama" log="[email protected]"></user>
</userlist>
</file>
What i want to do is to get in a variable my name from a specific log. For exemple get name if log = [email protected] what i tried was this
$PathXML="Path\conf.xml"
$xml = New-Object -TypeName XML
$xml.Load($PathXML)
$name = $xml.file.userlist.user | Select-Object -Property name | where log -eq "[email protected]"
The problem is that it returns me my log instead of my name. Thanks in advance for the help.
EDIT it doesn't return me my log but this @{name=Martin}
EDIT V2
after more research i found that my result was an Hashtable so all i have to do get the name is :
$var = $name.name