Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Please help me create a Powershell script that will go through an XML file and update content. In the example below, I want to use the script to pull out and change the file path in the Config.button.command example. Change C:\Prog\Laun.jar to C:\Prog32\folder\test.jar.

     C:\sy32\java.exe -jar "C:\Prog\Laun.jar" YAHOO.COM --type SPNG --port 80
       C:\sy32\java.exe -jar "C:\Prog\Laun.jar" YAHOO.COM --type JET --port 80
share|improve this question
$configFile = 'test.xml'

$xml = [xml](Get-Content -Path $configFile -Encoding Ascii)

foreach($button in $xml.SelectNodes('/config/button')) {

    $button.command = $button.command.Replace('C:\Prog\Laun.jar', 'C:\Prog32\folder\test.jar')

$xml.InnerXml | Out-File -FilePath $configFile -Encoding ascii
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .