Wednesday, January 22, 2014

PowerShell Script to run visual upgrade on all the migrated site collections

After migrating sites from SharePoint 2007 to SharePoint 2010, first thing usually we do is to visually upgrade the sites to look like SharePoint 2010 sites and not old 2007 look. You can perform this activity through Visual Upgrade page on Site Settings.
But if you have several site collections migrated from 2007 to 2010, the best way could be to use PowerShell to visually upgrade all the sites under all the site collections in a given web application.
You can easily customize this script to run it for single site collection as well.
1
2
3
4
5
6
7
8
#[System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral,PublicKeyToken=71e9bce111e9429c")

#Add SharePoint PowerShell Snapin which adds SharePoint specific cmdlets

Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue

$webApplicationUrl = "Name of the Web Application URL"
$webapp = Get-SPWebApplication $webApplicationUrl
Write-Host "Visually upgrading sites under" $webApplicationUrl
foreach ($s in $webapp.sites)
{
     $s.VisualUpgradeWebs()
}
Write-Host "Visually upgrade Completed Successfully"


No comments: