Hi,
I'm trying to create an array in a XML config file, then pass it through to a script but I am having problems creating the array in the script. It's recognising the data, but only as a string rather than an array... If that makes sense?
IE - my desired outcome would be like this.
$Servers = ('DPROVA01','DPROVA02')
foreach ($Server in $Servers) {
Write-Host $Server
}
So, the XML is
(the node)
add key="SERVERS" value="('QPROVA01','QPROVA02')"
And the script...
$xmldata = [xml](Get-Content C:\test\config.xml)
$Servers = $xmldata.configuration.appSettings.add | where { $_.key -eq "SERVERS" }
$Servers = $Servers.value
foreach ($Server in $Servers) {
Write-Host $Server
}
Can anyone point me in the right direction of building the array correctly? Any help would be appreciated.
Thanks in advance
Rob.