Add attribute to aspnet.config file

Welcome Forums General PowerShell Q&A Add attribute to aspnet.config file

This topic contains 1 reply, has 2 voices, and was last updated by

 
Keymaster
3 years, 7 months ago.

  • Author
    Posts
  • #23189

    Participant
    Points: 0
    Rank: Member

    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

  • #23190

    Keymaster
    Points: 2
    Rank: Member

    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 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.

The topic ‘Add attribute to aspnet.config file’ is closed to new replies.