SharePoint 2010–Extracting a .WSP Solution File Out of Your Farm

So any SharePoint consultant who has been out there for a while knows that sometimes you walk into a farm and it’s a mess.  Configurations aren’t right, which at least you have a good change of fixing… However, one of the more interesting situations is when you walk in and the farm is running fine, but the company has a bunch of .WSPs that are deployed to the farm and they don’t know what versions they are or what they do.  So how does one go about extracting a WSP from the farm so that we can then either deploy it to a migration farm or crack it open and reverse engineer it via a .CAB extractor?

Turns out that PowerShell makes it pretty easy for us to look like heroes.  Now why this very useful feature isn’t built into the UI I’ll never know, but if you log into the server and run these commands you’re able to quickly extract the .WSP files that have been deployed to the farm.

$farm = Get-SPFarm
$file = $farm.Solutions.Item("solution.wsp").SolutionFile

Obviously, just substitute the name of the solution you want to extract for the “solution.wsp” in the code.  And it really is just that easy.

What the Hell was NetFlix Thinking?

Sadly, I do own stock in NFLX, and looking back on how they’ve handled themselves this summer I have to say what the hell?  This company is probably a textbook case of how to take a perfectly good business model and run it into the ground.  Perhaps they were trying to encourage their competitors over at BlockBuster to stick around a bit longer?  Better yet, why take great brand recognition and create the Qwikster debacle?  Don’t take your perfectly good service and make it more expensive, harder to use, and alienate your customer base.  I can only assume that Mr. Reed Hastings didn’t want to pay so much tax on all those stock options he’s been exercising…

In the understatement of the year, this is what they had to say in their letter to investors:

While we dramatically improved our $7.99 unlimited streaming service by embracing new platforms, simplifying our user-interface, and more than doubling domestic spending on streaming content over 2010, we greatly upset many domestic Netflix members with our significant DVD-related pricing changes, and to a lesser degree, with the proposed-and-now-cancelled rebranding of our DVD service. In doing so, we’ve hurt our hard-earned reputation and stalled our domestic growth.

I think this graph says it all:


And that my friends, is how you cut 75% of your company’s market value before year end, make $12 billion in shareholder wealth plunge into the void and lose 800,000 subscribers.

SharePoint PowerShell–Delete Old Versions of Documents and Items

Within our SDLC farms (Dec, QA, UAT) we have limited amounts of resources.  As these are testing and integration environments there is often no reason to keep more than one or two copies of versions in the document libraries, especially as they are refreshed from production content databases on a regular basis.

Often there are 10-20GB of actual latest content, and 50GB of versions.  In some cases we can remove them from production, in others we only need to clear out all but the latest, as with the case of our SDLC farms.  Here is the PowerShell script that can be used to remove old versions.  You can set the limit lower for SDLC environments and higher if you want to trim production.

Get-SPWebApplication | Get-SPSite -Limit All | Get-SPWeb -Limit All | ForEach-Object { ForEach($list in $_.Lists) { If($list.EnableVersioning -eq $true) { $list.MajorVersionLimit = 1; $list.Update(); ForEach($item in $list.Items) { $item.URL; $item.SystemUpdate() } } } }


You can see that it…

  1. Gets all web applications in the farm
  2. All site collections
  3. All webs
  4. Loops through all lists  ( you can filter for Title if you wish: if($_.Title -eq "Shared Documents") in order ot only handle the default Shared Documents folder )
  5. If versioning’s enabled, it sets the major version limit to 1, you can set it higher for production environments
  6. In order to remove old versions, it needs to loop through each item and perform a system update

To keep a different number of versions, modify the MajorVersionLimit variable above.

SharePoint 2010 | Information Architecture Diagram Using PowerShell and Visio

As SharePoint consultants, we don’t always have the luxury of building our farms and the site structures from the ground up.  Sometimes we walk into a situation where the farm and sites have already been up for several years.  However, having a well-planned Information Architecture is critical for any successful SharePoint implementation.  As SharePoint gains in popularity and use, sites are created as one-offs, and after a while our environments start to run wild.  Sites are created without our knowledge or placed as sub-sites of other sites where they don’t really belong.  The power of SharePoint to make web technology accessible to the average information worker is also one of the biggest elephants in the room when it comes to proper and successful implementations.

At some point, whether you are designing the information architecture for the first time or you are going through a regular audit and review of your site structures, you’ll need to get the big picture.  What sites are where?  How do you start the conversation with management that site sprawl is affecting the usability of the system?  When dealing with management, the one thing I’ve learned is that they don’t want to see code or lengthy documents.  If you can’t get your point across in 2 minutes they’ll tune out.  So you have to start the conversation with a visual tool.  A graphical representation of the sites and subsites in a web application would be the perfect tool to give the 50,000 foot view of your sites.  Unfortunately we don’t get that out of the box with SharePoint.  However, this sort of diagram is easy to create with a little bit of PowerShell know how and some Visio diagramming wizards.

We’re looking to create a Visio diagram that makes it easy to visualize site and subsite structures.  The diagram should have relevant and important data about each site.  The layout should show how wide or deep our web application goes and allow us to find the sites that are buried deep inside out information architecture that should be brought up closer to the root.  If our information architecture is too wide we should be able to identify sites that can be pruned or moved under other sites in order to properly categorize them and make them more visible to the end user.

Gather SharePoint Data With PowerShell

Nobody would want to create this diagram by hand.  First off, imagine how long it would take if you had hundreds of sites.  Second, unless you have extremely tight governance controls already in place, the document would be outdated even before it was finished.The fist step is that we need to create a method of extracting the site hierarchy from the SharePoint farm that is easy and repeatable.  This is where PowerShell is a huge help for us.

  1. Remote to one of your SharePoint farm servers and open PowerShell
  2. Run the following PS command:
Get-SPWebApplication http://sharepoint| Get-SPSite -Limit All | Get-SPWeb -Limit All | Select Title, URL, ID, ParentWebID | Export-CSV C:\InfoArch.csv -NoTypeInformation

And what we get now is a nice set of records showing the following properties for each SPweb:

We could also choose to select additional properties of the SPWeb, it really depends on what other information you want to have available to you in the final Visio diagram.

Convert the CSV in Excel

Once we’ve created the CSV file with the elements we need for our Visio diagram, we need to go in and tweak a few things so that the final product formats correctly and shows a nice high level architecture.  In this case, we may find that there will be certain site collections with a ParentWebID GUID of “00000000-0000-0000-0000-000000000000″.  For our purposes, only the actual root of the web application should have this.  All the other site collections should be linked to the root by replacing their ParentWebID with the ID from the root site collection.  In order to do this:

1. Open the CSV file in Excel (Note: You’ll probably copy the CSV to your desktop, because MS Office should not be running on a SharePoint server)


2. To link all of the Site Collections to the root Site Collection, replace all ParentWebID’s that are “00000000-0000-0000-0000-000000000000″ (minus the Root’s) with the ID from the root Site Collection. So, in our example, all of the sites after the first record with a ParentWebID of “00000000-0000-0000-0000-000000000000″ would be replaced by the ID of the Root Site Collection “5b8bbd9b-1cb4-4c8f-a624-b464d08cd32c″ (except as noted where the first record is concerned).


3. Now that we have our data structured properly, save the file as XLSX so Visio can properly consume it as a data source.


Use Visio to Create the Information Architecture Diagram

1. Launch Visio 2010, and under the New selection, under the template categories you’ll want Business.  Select the Organization Chart Wizard

Visio 2010

Visio 2013 (Updated)

clip_image005 image


2. The wizard will start, choose ”Information that’s already stored in a file or database” and click Next


(I would update to show Visio 2013, but hey, they are the same dialog boxes!)

3. Choose “A text, Org Plus (*.txt) or Excel file, click Next.


4. Browse to where you saved the XLSX file and click Next.


5. Here is where the magic happens, instead of using the Employee/Manager relationships, we use ID for the Name, and ParentWebId for the Reports To fields.


6. This screen will be different, depending on what properties of the SPWeb you selected in your PowerShell script.  To keep it simple, I’ll just use the Title so that it will be the only label displayed on the diagram.


7. For shape data fields, it generally makes sense to leave all the columns in there.  This allows the Visio drill-down to be able to display all the relevant data about the SPWeb that you selected in your PowerShell scripts.  So for instance, if I had included the site owner property in my properties select, I would be able to click on a website shape and see who the site owner of the web was.


EDIT for Visio 2013: Don’t include pictures in my organization chart.


8. Select “I want to specify how much of my organization to display on each page” and click Next


9. For now, just keep the one page with your root Site Collection as the Employee at Top of Page and click Finish.


Once the Visio Organizational Chart Wizard completes its processing, you should have a single page diagram with the root Site Collection at the top of the page, and all the various sites and subsites under it (just like an org chart!).  Depending on how big your site is and your own computer processing power, this may take a few minutes to finish, so grab a cup of coffee and congratulate yourself on creating a great visual tool of your Information Architecture.

Explore the Visio Diagram of Your SharePoint Information Architecture

Once the process completes, you should have a single page Visio diagram with the Root at the top and Site Collections and subsites connected underneath.

EDIT: Visio 2013 diagram



Of course, when you select a particular site’s shape data, you can see all the additional information we chose to include from the SPWeb.


NOTE: Article edited to update to Visio 2013.

Use the Microsoft Virtual Academy for FREE training on SharePoint Online and Office365


The Microsoft Virtual Academy is a great resource and will help you improve your IT Skill set and help advance in your career with a free, easy to access training portal. You can learn at your own pace, focusing on Microsoft technologies, gain points and get recognition. The MVA is a free program delivering structured learning paths for IT Professionals on various Microsoft products and solutions.

If you are not yet registered on Microsoft Virtual Academy, it takes only a second to do so, please register here.

Also, go to the new TechNet Cloud Hub where you can get the ultimate resources on how Office 365 and collaboration work in the Cloud: Office 365 takes collaboration to the cloud with tools your users are already familiar with: Office, Exchange, SharePoint, and Lync videoconferencing.

Other great resources include the Evaluation Download Center where you can get free access to evaluations on practically any MS Software.