Created
April 15, 2013 08:12
-
-
Save chgeuer/5386610 to your computer and use it in GitHub Desktop.
Tweak an XML Document with Powershell and LINQ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Reflection.Assembly]::LoadWithPartialName("System.Xml.Linq") | |
| $roleroot = Get-Content Env:\RoleRoot | |
| $pathToPhp = "$roleroot\approot\php\php-cgi.exe"; | |
| $content = [System.IO.File]::ReadAllText("C:\PHP\web.config"); | |
| $doc = [System.Xml.Linq.XDocument]::Parse($content); | |
| $elements = $doc.Element("configuration").Element("system.webServer").Element("handlers").Elements("add"); | |
| $elementslist = [System.Linq.Enumerable]::ToList($elements); | |
| foreach ($e in $elementslist) | |
| { | |
| $e.Attribute("scriptProcessor").SetValue($pathToPhp) | |
| } | |
| [System.IO.File]::WriteAllText("C:\PHP\web.config", $doc.ToString()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment