Removing features from a content database in SharePoint 2010 using PowerShell

The great thing about the Health Analyzer in SharePoint 2010 is that it will report on a number of potential issues with the server farm, which may cause a problem later whilst applying a cumulative update or service pack. Resolving these issues in advance will help to prevent an update failing when you run the SharePoint Configuration Wizard.

One of these problems may occur when a solution is removed from the farm before the corresponding features were deactivated from site collections and sites. The Health Analyzer will place this issue in the “Configuration” category with the title “Missing server side dependencies”.

The error message reported will look similar to this one:

[MissingFeature] Database [WSS_Content] has reference(s) to a missing feature: Id = [d3fc1457-1a7b-46b1-a049-1fbef0db7415], Name = [AE Documents Rollup Web Part], Description = [Rolls up all new site Documents], Install Location = [AEDocsRollupWebpart]. The feature with Id d3fc1457-1a7b-46b1-a049-1fbef0db7415 is referenced in the database [WSS_Content], but is not installed on the current farm. The missing feature may cause upgrade to fail. Please install any solution which contains the feature and restart upgrade if necessary.

As shown above, this message reports a content database name (WSS_Content) and feature ID (d3fc1457-1a7b-46b1-a049-1fbef0db7415), but not the sites or site collections where the feature exists. In addition to this, even if you did know where the feature was activated, it will not appear anywhere in the UI for you to deactivate because the solution has been removed from the farm.

Using the PowerShell script developed by Phil Childs ( you can not only locate the feature in the farm but also remove it permanently.

Open PowerShell in Admin mode and paste the following:

Add-PSSnapin -Name Microsoft.SharePoint.PowerShell

function Remove-SPFeatureFromContentDB($ContentDb, $FeatureId, [switch]$ReportOnly)


$db = Get-SPDatabase | where { $_.Name -eq $ContentDb }

[bool]$report = $false

if ($ReportOnly) { $report = $true }

$db.Sites | ForEach-Object {

Remove-SPFeature -obj $_ -objName “site collection” -featId $FeatureId -report $report

$_ | Get-SPWeb -Limit all | ForEach-Object {

Remove-SPFeature -obj $_ -objName “site” -featId $FeatureId -report $report




function Remove-SPFeature($obj, $objName, $featId, [bool]$report)


$feature = $obj.Features[$featId]

if ($feature -ne $null) {

if ($report) {

write-host “Feature found in” $objName “:” $obj.Url -foregroundcolor Red




try {

$obj.Features.Remove($feature.DefinitionId, $true)

write-host “Feature successfully removed from” $objName “:” $obj.Url -foregroundcolor Red


catch {

write-host “There has been an error trying to remove the feature:” $_




else {

#write-host “Feature ID specified does not exist in” $objName “:” $obj.Url



To identify where the feature is installed on the farm use:

Remove-SPFeatureFromContentDB -ContentDB “WSS_Content” -FeatureId “d3fc1457-1a7b-46b1-a049-1fbef0db7415” –ReportOnly

To remove the feature from the farm use:

Remove-SPFeatureFromContentDB -ContentDB “WSS_Content” -FeatureId “d3fc1457-1a7b-46b1-a049-1fbef0db7415”

1 thought on “Removing features from a content database in SharePoint 2010 using PowerShell

Leave a Reply

Fill in your details below or click an icon to log in: Logo

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

Google photo

You are commenting using your Google 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 )

Connecting to %s