0

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 Answer 1

2

Try

[xml]$appContent = Get-Content C:\content.config
$appContent.Countries.add.Name
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.