Powershell - XML Insert a new line in an existing section

Viewed 2196

I have an unpacked default install of an XML file that comes pre-populated with XML settings, like this...

<system.web>
  <compilation targetFramework="4.6.1" debug="false" />
  <httpRuntime targetFramework="4.6.1" requestPathInvalidCharacters=""/>
</system.web>

I have a set of environmental changes to make on every release, so it adds one additional line to the system.web section...

<system.web>
  <compilation targetFramework="4.6.1" debug="false" />
  <httpRuntime targetFramework="4.6.1" requestPathInvalidCharacters=""/>
  <customErrors mode="Off" />
</system.web>

This is to be used in an Octopus deployment, which I believe uses Powershell 2.0 as its base.

In Powershell scripts, how can I just add the... customErrors mode="Off" / ...statement to the existing system.web section of that XML file?

Thanks in advance (prior linked duplicate question was not a concise answer - thanks)

1 Answers
Related