Update large number of xml config files

I had to update about 425 configuration files for web applications, which would be time consuming, 
so I wrote this quick and dirty automation. Here's it for your convenience:
Get a list of files you want to update:
Get-childitem-Path"W:\RFM*\install" -recurse -include "*.xml" | %{$_.fullname} | out-file C:\list_configfiles.txt

Read the file, update the contents of the xml files and save them:

Get-Content .\configfiles.txt` 
| %Write-Host"$_" -NoNewline
$xml = [xml] $(gc "$_"); 
ForEach($site in $xml.configuration.sites.site)
if( -not( $site.backup)) 
$backupnode.InnerXml ="<backup><enabled>true</enabled><schedule>weekly</schedule></backup>"
[Void] $site.AppendChild($backupnode

Write-Host" OK" 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s