How can i get variables from a config file in XML ?
I am actualy doing this using a .txt config file.
There is my actual code :
Config.txt
[Repertoire de SPO (generalement C:\SPO)]
destinationn="C:\SPO"
[Nom du sous repertoire de SPO (generalement : SPO1)]
sous_destination="SPO1"
[Numero de la version de SPO vers laquelle vous souhaitez upgrade (par exemple : 1812.4)]
version="1812.4"
[Nom du pool dapplication lie a SPO (par defaut SPO_ADV)]
applicationPoolName="SPO_ADV"
[Chemin de livraison de la nouvelle version de SPO (par defaut \\path\to\somewhere)]
livraisonn="\\path\to\somewhere"
Powershell.ps1
Get-Content "$current_path\config.txt" | foreach-object -begin {$h=@{}} -process { $k = [regex]::split($_,'='); if(($k[0].CompareTo("") -ne 0) -and ($k[0].StartsWith("[") -ne $True)) { $h.Add($k[0], $k[1]) } }
$destinationn = $h.Get_Item("destinationn")
I would like to do a similar thing using an .xml config file.
Get-IniContentfrom the TechNet Gallery which enables you to "parse" anini-like file to return the values as a HashtableConvertFrom-JsonCmdlet in PowerShell to read a JSON formatted file: serverfault.com/a/1032517/293696