# Edit XML file using DSC

**URL:** https://forums.powershell.org/t/edit-xml-file-using-dsc/3620
**Category:** DSC
**Created:** [January 13, 2015, 7:47pm UTC](https://forums.powershell.org/t/edit-xml-file-using-dsc/3620 "2015-01-13T19:47:30Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![aravinda-cat](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@aravinda-cat](https://forums.powershell.org/u/aravinda-cat)
#### Post date: [January 13, 2015, 7:47pm UTC](https://forums.powershell.org/t/edit-xml-file-using-dsc/3620/1 "2015-01-13T19:47:30Z")

</div>

Hi All,

I am working on a server setup using DSC. Intial setup for IIS needs the ApplicationHost.config file to be edited and modified. As this is a XML file, can we modify the tags of this file using any of the DSC module available?

If there is no module available for this task, Please guide me to create a custom module to complete this.

Thanks

---

<div class="post-metadata">

### Author: ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)
#### Post date: [January 14, 2015, 2:11am UTC](https://forums.powershell.org/t/edit-xml-file-using-dsc/3620/2 "2015-01-14T02:11:40Z")

</div>

I’m not aware of an existing XML-editing resource. You would need to build something custom, if that was the goal. “The DSC Book” has an overview of creating custom resource modules, and our DSC Hub links to our Git repo, where you can find several custom modules to use as examples.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)
#### Post date: [January 14, 2015, 2:49am UTC](https://forums.powershell.org/t/edit-xml-file-using-dsc/3620/3 "2015-01-14T02:49:41Z")

</div>

The WebAdministration module has several commands for managing IIS configuration files, without having to concern yourself with the XML directly. (Get-Command -Module WebAdministration -Name _config_). The DSC resource kit’s xWebAdministration module has a resource called xWebConfigKeyValue which might be what you’re looking for; it uses these WebAdministration commands to manage the files.

Note: For some reason, the “Wave 9” download of the DSC resource kit is missing some of the xWebAdministration resources, including xWebConfigKeyValue. It’s present in the Wave 8 download, though.

---

<div class="post-metadata">

### Author: ![aravinda-cat](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@aravinda-cat](https://forums.powershell.org/u/aravinda-cat)
#### Post date: [January 15, 2015, 10:14pm UTC](https://forums.powershell.org/t/edit-xml-file-using-dsc/3620/4 "2015-01-15T22:14:53Z")

</div>

Hi Dave,

Checked the xWebConfigKeyValue resource and it is configured to modify the Appsettings of the web.config file of the WebSite. As per my requirement , I need to modify the logfile path of the applicationhost.config file. Already the powershell script to do the job is as below :

Set-WebConfigurationProperty ‘/system.applicationHost/sites/siteDefaults/logfile’ -PSPath IIS:\ -Name directory -Value $logsPath

Can I modify the below parameters to run the above command?

xWebConfigKeyValue RecaptchaPublicKey  
{  
WebsitePath = $managementPortalInstallPath  
ConfigSection = ‘AppSettings’  
Key = ‘recaptchaPublicKey’  
Value = $Node.RecaptchaPublicKey  
DependsOn = ‘[File]ManagementPortalContents’  
}

---

<div class="post-metadata">

### Author: ![kottimon](https://avatars.discourse-cdn.com/v4/letter/k/a183cd/32.png) [@kottimon](https://forums.powershell.org/u/kottimon)
#### Post date: [February 18, 2016, 3:27am UTC](https://forums.powershell.org/t/edit-xml-file-using-dsc/3620/5 "2016-02-18T03:27:08Z")

</div>

With this module: [GitHub - dsccommunity/WebAdministrationDsc: This module contains DSC resources for deploying and configuring web servers and related components.](https://github.com/PowerShell/xWebAdministration) there is a setting you can use.  
eg.  
xWebSiteDefaults IIS  
{  
ApplyTo = ‘Machine’  
LogFormat = ‘W3C’  
AllowSubDirConfig = $true  
LogDirectory = ‘E:\LogFiles\IISLogs’  
DependsOn = “[WindowsFeature]IIS”  
}

---

<div class="post-metadata">

### Author: ![aravinda-cat](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@aravinda-cat](https://forums.powershell.org/u/aravinda-cat)
#### Post date: [February 18, 2016, 4:44pm UTC](https://forums.powershell.org/t/edit-xml-file-using-dsc/3620/6 "2016-02-18T16:44:43Z")

</div>

Thanks Guys,

It is already done and we can mark this completed.  
Working fine across all of my shared environment.

---

<div class="post-metadata">

### Author: ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)
#### Post date: [May 16, 2024, 9:17pm UTC](https://forums.powershell.org/t/edit-xml-file-using-dsc/3620/7 "2024-05-16T21:17:06Z")

</div>


