Sunday, May 6, 2012

How to swap between the WSS3 and Sharepoint 2010 user interfaces

I'm really starting to like all the great things you can do with Powershell, so I have decided to start to do some postings on the support it provides for Sharepoint. Powershell is, as the name implies, a powerful tool that can be used to manipulate almost anything on a server or client machine that makes use of  the  .NET Framework.   To get some ideas of what it can do, visit the official MSDN PowerShell Blog site here.

Today I'm going to present a little piece of code that does the opposite of what  I'd think many Sharepoint users want,  reverting the UI back to the older wss3 look and feel.  The code snippet below takes a given Site Collection url and changes the user interface on all its subsites.

$SiteCollection=Get-SPsite http://<sitecollection_url>
foreach($SPWeb in $SiteCollection.AllWebs)
{
$SPWeb.UIVersionConfigurationEnabled=$true;
$SPWeb.UIVersion=3;
$SPWeb.Update();
}  

The script uses the Get-SPSite cmdlet to get a reference to a site collection, then it uses the AllWebs property of the SPSite class to return all the web sites in the collection and loops through each of them.
Setting the UIVersionConfigurationEnabled property to true enables swapping between UI versions, while UIVersion is set to 3 to activate the WSS3 interface. Finally the SPWeb Update() method is  called to store the changes in the content database.

To restore the 2010 interface, simply change UIVersion to 4 and rerun the script.



No comments:

Post a Comment