PowerShell SharePoint Features Comparison

SNAGHTML1b627dd6

One example of how PowerShell can help you in your SharePoint migration and upgrade tasks is directory comparison. I’ve used many tools for directory comparison before, but this is hands down the easiest when PowerShell is already installed. In three lines, you have a list of Features installed on one web front end but not the other.

PowerShell Basics

The solution is based on two out of the box PowerShell commands and one PowerShell principle.

  1. Dir command – lists the files and folders in a directory
  2. Compare-Object command – given two lists, display the differences
  3. $variables assignment – assign the directory listing to a variable for use later

My Scenario

Starting a new project, I was faced with the challenge of reproducing some of an existing farm on my development machine. I was given installation instructions and a copy of the 12 hive. After following the instructions, the customizations were failing on a missing feature. Using the powershell script above to compare my new SharePoint Root TemplateFeatures directory to the copy from production, I was able to identify the missing features and subsequently locate the Solution Package that hadn’t been included in the installation instructions.

Applications for Upgrade and Migration

Besides development, SharePoint upgrades and migrations are both common scenarios when directory comparison is important. Through some trial and error, you may be able to determine SharePoint Root Directory modifications that were made manually versus those deployed through SharePoint Solution Packages. Install a package, compare to the root you are trying to reproduce and repeat, until you’ve added all of the solution packages you have available. The Features that still show are the ones deployed manually or by packages you don’t have. Create a package for the new features and you will be ahead of the game next time you need to add a Web Server to your Farm or upgrade to SharePoint 2010.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.