#Script: UpgradeSharePointList #Author: Peter Heydon (www.heyweb.net) #Date: 16 September 2010 #Purpose: This script will convert a SharePoint 2007 list template to be SharePoint 2010 compatible. # #Credit for defining the conversion process: http://tom-dw.blogspot.com/2010/06/importing-sharepoint-2007-list.html #Credit for calling 7-Zip from Powershell: http://mats.gardstad.se/matscodemix/2009/02/05/calling-7-zip-from-powershell/ #Everything else cobbled together from Microsoft TechNet # #Requirements: # Three folders: input (SharePoint 2007 list templates) # output (SharePoint 2010 compatible list templates) # processed (SharePoint 2007 list templates that have been processed) # 7z.exe (from 7-Zip installation: http://www.7-zip.org/) # makecab.exe (should be in your WINDOWS installation folder) # #WARNINGS: There is zero error handling, so don't expect the script to be gracefull. The script is supplied # 'as is' and should be tested thoroughly before using in a production environment. ### DEFINITIONS $RootDir = "\\server\share\path\" #Ensure it has a trailing backslash ('\') Set-Alias sz ("C:\path\to\7zip\7z.exe") Set-Alias mcab ("C:\windows\system32\makecab.exe") # Get list of all STP files $InputDir = get-childitem ($RootDir + "input") foreach ($item in $InputDir | where {$_.extension -eq ".stp"}) { $targetFile = ($RootDir + "input\" +$item.name) $extractPath = $targetFile.substring(0,$targetFile.length-4) "Processing: " + $targetFile #Create directory New-Item $extractPath -type directory #Expand STP File $extractPathOption = ("-o" + $extractPath) sz x $extractPathOption $targetFile #Replace files $manifestFileIn = $extractPath + "\manifest.xml" $manifestFileOut = $extractPath + "\manifestOut.xml" (Get-Content $manifestFileIn | Foreach-Object {$_ -replace "<ProductVersion>3</ProductVersion>", "<ProductVersion>4</ProductVersion>"} | Set-Content $manifestFileOut) #Cleanup files Remove-Item $manifestFileIn Rename-Item $manifestFileOut $manifestFileIn #Recompress (MakeCab) $itemNoExtension = $item.name.substring(0,$item.name.length-4) $CabFileName = ($RootDir + "\output\" + $itemNoExtension + ".cab") $NewSTPFileName = ($RootDir + "\output\" + $itemNoExtension + ".stp") mcab $manifestFileIn $CabFileName #Rename cab, and move to output folder Rename-Item $CabFileName $NewSTPFileName Remove-Item $manifestFileIn Remove-Item $extractPath #Move original file to processed folder Move-Item $targetFile ($RootDir + 'processed') } |
I have a scheduled task now running every 10 minutes during the day that will process all files in the input folder. The process is simplified, I’m not having to get involved, so everyone is happy! Click here in order to Buy Windows 7 Ultimate Online for your office or home pc.
