Find all activated Web Analytics Features

When upgrading SharePoint 2010 to SharePoint 2013 the web analytics service application and features should be removed prior to the upgrade process. This is because web analytics is now part of the Search architecture. It is no longer a service by itself.

While reading this TechNet article : http://technet.microsoft.com/en-us/library/cc263026(v=office.15).aspx#Before I find this particular paragraph interesting:

Web Analytics  The architecture for the Web Analytics service application is different in SharePoint 2010 Products. The presence of SharePoint Server 2010 Web Analytics information in your content databases could cause an error during upgrade. Stop the Web Analytics service application before you back up the content databases. Features and web parts from Web Analytics in SharePoint Server 2010 will not exist in SharePoint Server 2013, even for a site collection in 2010 mode. Remove any Web Analytics web parts or features from SharePoint Server 2010 site collections before upgrade.

Stopping and removing the service application is easy. There is probably just one running. However, there could a lot of features activated if you have a large environment with lots of site collections. I guess you’ll need a script to do the hard work for you.

First of all, what Web Analytics features are there? In my browser favorites list I have a MSDN Blog post summarizing all SharePoint 2010 features: http://blogs.msdn.com/b/mcsnoiwb/archive/2010/01/07/features-and-their-guid-s-in-sp2010.aspx 

So, we have 8 features: 2 are farm features, 2 are for Central Administration and 4 are site collection features.

Basically, the cmdlet Get-SPFeature is all you need. Take a look at the following code snippet:

Write-Host "Checking Farm..."
# WAEnterpriseFeatureStapler Web Analytics Enterprise Feature Stapler
$farmFeature = Get-SPFeature c0c2628d-0f59-4873-9cba-100dad2313cb -Farm -ErrorAction SilentlyContinue
if( $? )
{
    Write-Host "`tWeb Analytics Enterprise Feature Stapler" -NoNewline
    Write-Host -f Red " [Active]"
}

The Get-SPFeature checks if the given FeatureID is active in the Farm. If not, it throws an exception. I like a readable output, so long exception messages in read I like to handle that differently. That’s why I use the $? variable here. It tells you is if the last command was successful (True) or unsuccessful (False). If the Get-SPFeature commnd was successful, the feature is active!

Next step is to loop through all web applications and site collections. This is done using the cmdlet Get-SPWebApplication. Then loop through the Site Collections using the property Sites of a SPWebApplication object. Take a look at the following code snippet:

$allWebApps = Get-SPWebApplication
foreach( $webApp in $allWebApps )
{
    
    foreach( $site in $webApp.Sites )
    {
        
        #WAWhatsPopularWebPart Web Analytics WebPart
        $siteFeature = Get-SPFeature 8e947bf0-fe40-4dff-be3d-a8b88112ade6 -Site $site.Url -ErrorAction SilentlyContinue
        if( $? )
        {
            Write-Host "`tWeb Analytics WebPart" -NoNewline
            Write-Host -f Red " [Active]"
        }

        $site.Dispose()
    }
}

When running the script, it looks like this:

Scan-WebAnalyticsFeatures

The complete script can be downloaded from the Assets page. It also contains two switches. One for log all output to a file and one to indicate that all active features should be disabled.

Share