locked
Uncomment a tag in web.config RRS feed

  • Question

  • Dear All,

    I have a tag in web.config like this

    <assemblies>
    <!--<add assembly="Telerik.Reporting, Version=4.2.10.1221, Culture=neutral, PublicKeyToken=A9D7983DFCC261BE" />-->
    </assemblies>

    I need a powershell  script that can uncomment this tag.

    Any help would be greatly appreciated

    Monday, September 17, 2018 1:50 PM

Answers

  • We do not write scripts on request.

    Get-Content web.config | 
        ForEach-Object{
            $_ -replace '<!--<add assembly="Telerik.Reporting, Version=4.2.10.1221, Culture=neutral, PublicKeyToken=A9D7983DFCC261BE" />--></assemblies>','<add assembly="Telerik.Reporting, Version=4.2.10.1221, Culture=neutral, PublicKeyToken=A9D7983DFCC261BE"/></assemblies>'
        }



    \_(ツ)_/


    • Edited by jrv Monday, September 17, 2018 2:27 PM
    • Marked as answer by Sammy Williams Wednesday, October 24, 2018 2:25 PM
    Monday, September 17, 2018 2:25 PM

All replies

  • We do not write scripts on request.

    Get-Content web.config | 
        ForEach-Object{
            $_ -replace '<!--<add assembly="Telerik.Reporting, Version=4.2.10.1221, Culture=neutral, PublicKeyToken=A9D7983DFCC261BE" />--></assemblies>','<add assembly="Telerik.Reporting, Version=4.2.10.1221, Culture=neutral, PublicKeyToken=A9D7983DFCC261BE"/></assemblies>'
        }



    \_(ツ)_/


    • Edited by jrv Monday, September 17, 2018 2:27 PM
    • Marked as answer by Sammy Williams Wednesday, October 24, 2018 2:25 PM
    Monday, September 17, 2018 2:25 PM
  • Hi Sammy,

    Thanks for your question.

    I agree with jrv's reply. Text-manipulation using regex. Find something unique in the line you want to uncomment.

    After you replace it, you can also use "Set-Content" cmdlet to replace new content your web.config file.

    Set-Content -path web.config

    Best regards,

    Lee


    Just do it.

    Tuesday, September 18, 2018 7:06 AM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    Best Regards,

    Lee


    Just do it.

    Monday, October 8, 2018 5:41 AM