-4

I have an XML file and need to change the value to False. Is there a way to do this with powershell?

<setting name="RecordChatHistory">
    <value>True</value>
  </setting>
Michael X
  • 1
  • 1
  • 1

1 Answers1

2

You can do it this way.

  1. Loading xml

    $xml = [xml](Get-Content -Path C:\path\to\file.xml)

  2. Replacing string value True to False

    $xml.setting.value = 'False'

  3. Using the Save() method

    $xml.Save("C:\path\to\file.xml")

zorski
  • 21
  • 1
  • 1
    Thanks, But there are multiple value tags. I don't want to replace them all. – Michael X Oct 26 '18 at 20:42
  • 2
    You should have mentioned that in the question... for more advanced filtering of xml you could look into XPath – zorski Oct 26 '18 at 21:39
  • 1
    @MichaelX this does answer your question. Please accept the answer, then ask a new question with the right information and what you seek. – LPChip Oct 26 '18 at 22:39