dimanche 28 juin 2015

Powershell Reading XML file

So I'm attempting to read to following xml config file.

<configuration>
<userSettings>
    <setting name="FavoritesFolders">
        <value>
            <FavoritesFolder>
                <Subfolders>
                    <FolderName>ROOT</FolderName>
                </Subfolders>
            </FavoritesFolder>
        </value>
    </setting>
    <setting name="DefaultConnection">
        <value>
            <RDPConnectionProperties>
                <serverName>TextServerName</serverName>
            </RDPConnectionProperties>
        </value>
    </setting>

So how would I read the different setting sections via their 'name'.

For Example; I if I would like to read the serverName in the "<setting name="DefaultConnection>" section.

So fair, I've only been able to achieve the following;

$xml = New-Object XML
$xml.Load("$home\user.config")
$xml.configuration.userSettings

name
----

FavoritesCollection
DefaultConnection

Aucun commentaire:

Enregistrer un commentaire