Converting SharePoint 2007 list templates for SharePoint 2010

I’m hot on the heels of a SharePoint 2007 to 2010 migration project.  It had been decided not to upgrade, but to transition all of the content across and try and make better use of the document management features of SharePoint from scratch.

One of the first problems we discovered was for bringing across list libraries.  This was to be a simple task, simply save the list as a template, import into the new environment and it should just work. Unfortunately, I was greeted with an error along the lines of version 3 templates are not supported in this version of the product“.

Searching for the error, I came across the answer in this blog post of Importing SharePoint 2007 list templates (STP) into SharePoint 2010.

Tom’s solution  worked great, but there was no way I could get general users to extract the list template, edit the XML and re-package.  So I wrote this small PowerShell script:
#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 "&lt;ProductVersion&gt;3&lt;/ProductVersion&gt;", "&lt;ProductVersion&gt;4&lt;/ProductVersion&gt;"} | 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! 29 thoughts on “Converting SharePoint 2007 list templates for SharePoint 2010” 1. René says: Thanks for sharing, your solution is of great value to me! 2. venkat says: Hello Peter, First of all this post is of very useful for eveyone, i tried this script but no success for me. Plz provide best solution to work this script.$RootDir = “\\server\share\path\” here which path should i mention and how to provide exactly plz provide an example that way it will be very helpful. I provided my local machine path where input,output and processed folders are present.

1. Peter Heydon says:

Hi Venkat,

An example for your local machine would be to have three folders: “c:\temp\input”, “c:\temp\output”, “c:\temp\processed”

Therefore: $RootDir = “c:\temp\” Hope that helps. Cheers, Peter 3. venkat says: Hello Peter, Thank you for your quick response. The same as you mentioned i tried still it is not updating product version 3 to 4 in output folder. i am able to see the .stp list templates in all the output and processed folders as is. no update of product version. Please help me in this regard that am i doing any mistake. 4. venkat says: Hello Peter, i found the solution i.e instead of Foreach-Object {$_ -replace “<ProductVersion>3</ProductVersion>”, “<ProductVersion>4</ProductVersion>”} we should use Foreach-Object {$_ -replace “3”, “4”} now it will work fine 1. Peter Heydon says: Hi Venkat, Yes, your changes will work and upgrade the product version fine, however, please be careful because if you have a “3” anywhere else in your list (ie date, phone number, dollar amount) I would expect this will also be converted to a “4”. Cheers, Peter 1. Srikanth says: It worked for me with this code: (Get-Content$manifestFileIn | Foreach-Object {$_ -replace “3”, “4”} | Set-Content$manifestFileOut)

Thanks for the solution, was very helpful.

1. Srikanth says:

Sorry – ignore my previous reply , it worked for me with the proper tags- (Get-Content $manifestFileIn | Foreach-Object {$_ -replace “3”, “4”} | Set-Content $manifestFileOut) Thanks for the solution, was very helpful. 1. Harish says: I think it converts all the 3 in the manifest to 4. This is wrong. It has changed the LanguageID which was previously 1033 to 1044. Also the 3 feature guid. 2. Harish says: Sorry. I think I missed the ProductVersion tag 5. Peter says: Worked perfectly just copied and pasted into script, the conversion completed with no errors first time. Thank you a great script. Peter Hassan 6. Chee says: This solution is great! Does this solution moves the content that is present in the original stp? 7. Chee says: Noticed that this migrates the content of the custom list,however for document libraries,it only creates the structure but doesnt migrates the content. Is there any extra setting in the powershell that can help? Thanks.. 8. Harish says: I think it converts all the 3 in the manifest to 4. This is wrong. It has changed the LanguageID which was previously 1033 to 1044. Also the 3 feature guid. 9. George says: Not that I’m complaining about free code to solve my problem, but why use the “<” crap (which doesn’t work on Win7 Powershell) rather than this code which actually works: (Get-Content$manifestFileIn | Foreach-Object {$_ -replace “3<", "4<"} | Set-Content$manifestFileOut)

I do thank you for the 95% solution which mostly works (although it doesn't change the product version), and if I were an actual programmer, I no doubt would've caught the 5% that's garbage…was this just a teaser post to get folks to call you in for the real solution?

10. George says:

Posting problem; Text should read (assuming I have correctly used the html tag:

<blockquote cite="(Get-Content $manifestFileIn | Foreach-Object {$_ -replace "3<", "4

11. George says:

Last Time. WHat worked for me was venkat’s first modification, without the slash ProductVersion after the ‘less than symbol’

12. sathishkumar says:

Hi thanks it greatly works for me with out power shell script.
i will write a .net apps and share

13. Ammar Yasir says:

On running the script I am getting the following error:

Cabinet Maker – Lossless Data Compression Tool

ERROR: Could not find file: C:\inetpub\temp\input\templatename\manifest.xml

Can anyone me in this regard?

Thanks!

14. Ray says:

Hi, Peter,
I have been able to use this approach to convert all my sharepoint 2007 list to Sharepoint 2010 successfully. but the main list that uses other list as lookup fields is failed to create, I got error, with correlation ID = {….}, I found that all the data was imported, but all views were not imported and NewForm.aspx, EditForm.aspx and DispForm.aspx are missing, I cannot insert new form neither, it returns (“cannot save changes to the server”).

I have all the New, Edit, Disp form customized. by the way, I cannot find the errors in the log files neither, I even searched using Correlation ID.

Can you shine some light on this? I am stuck .

Ray,

15. Falak says:

Try to find all List Templates within all site collections and download them all on the disk (in their separate folders i.e. for each site collection a separate folder is created)
Upgrade the List templates using the PowerShell
Upload them back to their original site collections

Here is the complete solution:

16. Syed uzair uddin says:

How i can Use Product Catalog template(site collection)..
while i am using SharePoint Foundation 2013..
do tell if there is any method to use it, or any extension???

17. I see a lot of interesting posts on your page. You have to spend a lot of time writing, i know how to save you a lot
of work, there is a tool that creates high quality, SEO friendly posts in couple of
minutes, just type in google – k2 unlimited content

18. First coming from all, it is important to figure out which you need to influence, and after that understand
the relationships you and your boss have with him or her. But, he combined his
left-brain thinking ability with very right-brain approaches.

Your core level identity transcends heredity, religion, race and society.