0
votes

I need to read a value of a config file and save it to a variable and then print to the screen. When I executed the below script I get an empty string for $value printed on the console.

$appContent = GET-CONTENT C:\content.config
$value = $appContent.Countries.add
Write-Host $value

Content of C:\content.config file

<Countries>
    <add name="Serbia"  />
</Countries>
1

1 Answers

2
votes

Try

[xml]$appContent = Get-Content C:\content.config
$appContent.Countries.add.Name