Migrate a SharePoint Team Wiki to an Enterprise Wiki

Perhaps someone has also migrated his old SharePoint 2007 Team Wiki to SharePoint 2010 and wants to have the cool features from an Enterprise Wiki.

I searched a while and I think the best way to do this is to migrate with PowerShell. The List Wiki and the Enterprise Wiki are using different fields so there will be no other way I thing but PowerShell or manually.

So the great script for your use. Just adapt the settings for your environment.

 <# PowerShell Script to migrate Team Wikis into Enterprise Wiki Pages #>  
   
 # Setup Basic sites and pages  
 $webappURL     = "http://sharepoint-uat"  
 $wikiSiteURL  = "$webappURL/sites/serverplatforms"        
 $wikiWebURL    = "$wikiSiteURL/wiki"              
 $pageFolder    = "/Seiten/"  
   
 $oldWikiWeb   = "$webappURL/sites/serverplatforms"  
 $wikiListName  = "Team Wiki"  
   
 try   
 {  
   Write-Host " >> STARTING MIGRATION ..." -foregroundcolor green  
   Write-Host "   1. GETTING SiteColletion: $wikiSiteURL" -foregroundcolor green   
   $wikiSite   = Get-SPSite $wikiSiteURL  
   $psite     = New-Object Microsoft.SharePoint.Publishing.PublishingSite($wikiSite)   
   
   Write-Host "   2. GETTING ENTERPRISE WIKI WEB: $wikiWebURL" -foregroundcolor green   
   $web     = Get-SPWeb $wikiWebURL  
   $pweb     = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)  
   $pages     = $pweb.GetPublishingPages($pweb)  
   
   Write-Host "   3. GETTING WIKI PAGE LAYOUT" -foregroundcolor green   
   $ctype     = $web.AvailableContentTypes | ? { $_.Name -eq "Enterprise Wiki Page"}  
   $layouts   = $psite.GetPageLayouts($ctype, $true)  
   $layout   = $layouts[0]  
   
   # OLD WIKI  
   Write-Host "   4. GETTING OLD WIKI" -foregroundcolor green   
   $wikiWeb  = Get-SPWeb $oldWikiWeb  
   $wiki     = $wikiWeb.Lists[$wikiListName]  
   
   Write-Host "   5. LOOPING THROUGH THE WIKI LIST ITEMS" -foregroundcolor green   
   $i = 0;  
   foreach ($oldItem in $wiki.Items) {  
     Write-Host ""  
   
     # Create a new page in the enterprise wiki  
     $name     = $oldItem["ows_BaseName"]  
     if ($name -eq "home") {  
       continue;  
     }  
     Write-Host "     >> MIGRATING ITEM: $name" -foregroundcolor yellow    
     $strDestURL = $wikiWebURL + $pageFolder + $name + ".aspx"  
       
     Write-Host "     >> NEW URL IS: $strDestURL" -foregroundcolor yellow  
     $page     = $pages.Add($strDestURL, $layout)  
       
     Write-Host "     >> CHANGING PAGE PROPERTIES" -foregroundcolor yellow  
     $item       = $page.ListItem      
     $author     = $oldItem["ows_Created_x0020_By"]  
     $userID     = $web.EnsureUser($author).ID  
     $item["Title"]   = $name  
     $item["Editor"] = $userID  
     $item["Author"] = $userID      
       
     # Replace the links in the new content  
     $content   = $oldItem["ows_WikiField"]  
     $newContent = $content -replace "/Team%20Wiki/", "/wiki/Seiten/"    
       
     # Add new content to the page  
     $item["ows_PublishingPageContent"] = $newContent  
     $item.SystemUpdate($false)  
     $i++;  
   }  
   
   Write-Host "   6. MIGRATION FINISHED !!" -foregroundcolor green   
   Write-Host "     >> MIGRATED $i SITES." -foregroundcolor yellow  
   $site.Dispose()  
   $web.Dispose()  
 }  
 catch [System.Exception] {  
   Write-Host "Error while migration Wiki List...`n" -foregroundcolor red  
   $_.Exception.ToString();    
   exit  
 }   

Comments

Anonymous said…
is there a way that we can migrate enterprise wiki site to team site in sharepoint 2010.
Baris Bikmaz said…
Personally I would copy the enterprise wiki site as subsubsite under the team site. But you modify the script above by looping through the pages library of the enterprise wiki and adding the content to an item in the team wiki list. The modifications should be easy.

Popular posts from this blog

Open SharePoint 2010/2013 Display, Edit, New Forms in Modal Dialogs

Ways to redirect http requests in SharePoint

Using WebDav on IIS 7 to access UNC Paths