Editing XML file?

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Don Jones Don Jones 3 years, 9 months ago.

  • Author
    Posts
  • #8827
    Profile photo of Kitt Holland
    Kitt Holland
    Participant

    Hello, have a question about updating an XML doc.

    I have an unattend.xml file I've brought into powershell by:
    [xml]$Unattend = Get-Content \\share\unattend.xml

    I can view a value I want to change by:

    $Unattend.unattend.settings.component.interfaces.interface.dnsdomain

    When I run that command it returns system.string 'test.local'

    I want to update the domain to 'test2.local'

    I have tried $Unattend.unattend.settings.component.interfaces.interface.dnsdomain = 'test2.local' but I get:

    "Property 'dnsdomain' cannot be found on this object; make sure it exists and is settable.

    Any ideas how I can change that value?

  • #8835
    Profile photo of Don Jones
    Don Jones
    Keymaster

    Yeah, the XML object model is a bit difficult to work with. We did a chapter on this in "PowerShell In Depth," do you happen to have a copy of that?

You must be logged in to reply to this topic.