# Add attribute to aspnet.config file

**URL:** https://forums.powershell.org/t/add-attribute-to-aspnet-config-file/3855
**Category:** PowerShell Help
**Created:** [March 10, 2015, 1:12am UTC](https://forums.powershell.org/t/add-attribute-to-aspnet-config-file/3855 "2015-03-10T01:12:59Z")
**Posts on this page:** 3
**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: [March 10, 2015, 1:12am UTC](https://forums.powershell.org/t/add-attribute-to-aspnet-config-file/3855/1 "2015-03-10T01:12:59Z")

</div>

Hi All,

I am working on a server migration where some attributes need to be added to the ASPNET.config(%systemroot%\microsoft.net\framework\v4.0.30319) file using powershell cmdlet.  
As, this is a kind of XML file , can anybody guide me how to add the below attribute to the file :

.gcTrimCommitOnLowMemory enabled=“true”  
The above attribute will be placed inside .Configuration.Runtime tag.

Thanks,  
Aravinda

---

<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: [March 10, 2015, 1:19am UTC](https://forums.powershell.org/t/add-attribute-to-aspnet-config-file/3855/2 "2015-03-10T01:19:06Z")

</div>

Do you have “PowerShell in Depth” by any chance? There’s an excellent chapter on manipulating XML, loading XML documents, adding elements and attributes, and so on.

Otherwise:

[xml]$xml = Get-Content filename.xml

Loads an XmlDocument object; [https://msdn.microsoft.com/en-us/library/system.xml.xmldocument(v=vs.110).aspx](https://msdn.microsoft.com/en-us/library/system.xml.xmldocument(v=vs.110).aspx) describes how those work and what you can do with them. Use SelectSingleNode() to find the node you want, for example. CreateAttribute() creates a new attribute, and so on.

---

<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, 8:46pm UTC](https://forums.powershell.org/t/add-attribute-to-aspnet-config-file/3855/3 "2024-05-16T20:46:15Z")

</div>


