Tuesday, May 15, 2012

InfoPath form Migration

I needed to move a bunch of InfoPath forms from one library to another, because I re-created the infopath template on a new server.  I needed to preserve the historical data, however, the individual forms (XML Files) reference the old library, so I needed to change all of the URLs in all of the XML files to point to the new server. This script allowed me to do that.

$files = get-childitem .\ToDo

foreach ($file in $files){
     (Get-Content c:\XmlFiles\ToDo\$file) |
     Foreach-Object {$_ -replace      "http://OldSiteCollection/Path/Forms/template.xsn",      "http://NewSiteCollection.com/path/Forms/template.xsn"} |
     Set-Content c:\XmlFiles\Done\$file
}

I copied all of the InfoPath forms to a directory (c:\XmlFiles\ToDo) on my computer and created an output directory (c:\XmlFiles\Done), then ran the script.

No comments:

Post a Comment