Upgrading to SharePoint 2010 look and feel

Problem

After a recent SharePoint 2007 to 2010 upgrade (via database attach method) to one of our medium-sized web application, we were stuck with the old MOSS 2007 look and feel for SharePoint functionality. Moreover pretty much all our sites use several custom master pages. Doing a Visual Upgrade would reset all the sites to v4.master and would completely remove the custom master pages.

The task was to find an easy way to switch the look and feel for SharePoint functions to v4, but still retain our custom master pages for our sites. Yes we could have done it individually and manually, but why fret if the mighty PowerShell handy-man is around.

Solution

Iterate over the sites, remember the old master pages, reset the UI version and reset the old master pages.

Before running the scripts, it is useful to take a look at the web page for changing master page layouts http://sharepoint-web-app/<site>/_layouts/ChangeSiteMasterPage.aspx. There are two fields Site Master Page and System Master Page. The former is for publishing pages and the later is for forms and views (think AllForms.aspx and Views.aspx).


$rootSite = get-spsite("http://sharepoint-web-app")
$webs = $rootSite.AllWebs
foreach($w in $webs) {
 Write-Host
 Write-Host $w
 Write-Host "       " -Separator ": " $w.CustomMasterUrl $w.MasterUrl

 # CustomMasterUrl is the Site Master Page
 $oldCustomMasterUrl = $w.CustomMasterUrl
 # MasterUrl is the System Master Page
 $oldMasterUrl = $w.MasterUrl
 $w.UIVersion = 4
 $w.UIConfigurationVersionEnabled = $false
 # At this point, the CustomMasterUrl is set to v4.master
 $w.Update()
 # Reset to old master pages
 $w.CustomMasterUrl = $oldCustomMasterUrl
 $w.MasterUrl = $oldMasterUrl
 $w.Update()
}
$rootSite.Dispose()

The script iterates over all the sites and sub-sites, remembers their old master pages, switches to v4.master and resets the sites to old master pages. In effect, the Site Settings and other pages will have the SP 2010 look and feel.

About these ads

6 Responses to Upgrading to SharePoint 2010 look and feel

  1. cssathya says:

    Powershell is one really useful thing that MS added to the new version. The code is helpful, but you should also dispose the $w that you get in the loop as per their best practices.

    You can use the SPDisposeCheck against the code to see if there are any memory leaks. http://msdn.microsoft.com/en-us/library/aa973248.aspx

    I am not sure if it makes a difference here since this is a stand-alone command and runs only once, but it’s better to be safe.

    Like

  2. Lallo Vigil says:

    Do you use this after the visual upgrade then?

    Like

  3. vasya10 says:

    @Lallo:

    No, this is an alternative to Visual Upgrade. If you have custom master pages *and* use Visual Upgrade, the custom master pages may be replaced with the new v4.master, which may screw up your UI. But here, you retain the old custom master pages for your site, and only use the v4.master for the system pages (ie all pages accessed via Site Actions menu). So your Site Actions pages will automatically get the new ribbon styling.

    If you have heavily customized master pages, after upgrading, you will have to do a few fixes for SharePoint 2010 (like adding ribbon tags, permissions etc) manually.

    Like

  4. Lallo Vigil says:

    I get the following error:

    Any suggestions?

    $rootSite.Dispose() : Exception has been thrown by the target of an invocation.
    + CategoryInfo : NotSpecified: (:) [], TargetInvocationException
    + FullyQualifiedErrorId : System.Reflection.TargetInvocationException

    Like

  5. vasya10 says:

    @Lallo: I probably wouldnt worry about it. I think the Dispose() works well if site is created via New-Object SPSite(). Here we created via get-spsite.

    Like

  6. Pingback: Visual Upgrade Troubleshooting « Jimblog

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 189 other followers

%d bloggers like this: