Pages

19 October 2011

Solving [MissingWebPart] errors from SharePoint Health Analyzer

ISSUE DESCRIPTION:
After a SharePoint 2007 Migration to SharePoint 2010, on the Central Administration, the SharePoint Health Analyzer is generating the critical event [Missing server side dependencies] :

And the event details is generating a lot of [MissingWebPart] errors, examples:
[MissingWebPart] WebPart class [36f2680f-4855-f100-da5b-5dd1d07ae62b] is referenced [1] times in the database [Sharepoint_80_Content_01], but is not installed on the current farm. Please install any feature/solution which contains this web part. One or more web parts are referenced in the database [Sharepoint_80_Content_01], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
[MissingWebPart] WebPart class [d0d5a8f7-2e30-7cd0-276e-7cdc1aac9ab8] is referenced [21] times in the database [Sharepoint_80_Content_01], but is not installed on the current farm. Please install any feature/solution which contains this web part. One or more web parts are referenced in the database [Sharepoint_80_Content_01], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
[MissingWebPart] WebPart class [7dac9698-9043-eb31-b853-be8c1705512b] is referenced [1] times in the database [Sharepoint_80_Content_01], but is not installed on the current farm. Please install any feature/solution which contains this web part. One or more web parts are referenced in the database [Sharepoint_80_Content_01], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
[MissingWebPart] WebPart class [150b4681-ae25-d7be-bc71-1410062c7315] (class [Microsoft.AnalysisServices.SharePoint.Integration.DataRefreshHistoryWebPart] from assembly [Microsoft.AnalysisServices.SharePoint.Integration, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91]) is referenced [1] times in the database [Sharepoint_80_Content_02], but is not installed on the current farm. Please install any feature/solution which contains this web part. One or more web parts are referenced in the database [Sharepoint_80_Content_02], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
[MissingWebPart] WebPart class [60085034-7d97-27c7-5823-2f941e6be1de] (class [Microsoft.AnalysisServices.SharePoint.Integration.WorkbookWebPart] from assembly [Microsoft.AnalysisServices.SharePoint.Integration, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91]) is referenced [1] times in the database [Sharepoint_80_Content_02], but is not installed on the current farm. Please install any feature/solution which contains this web part. One or more web parts are referenced in the database [Sharepoint_80_Content_02], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
[MissingWebPart] WebPart class [7a95935f-d524-5992-f505-809725b6a9e2] (class [Microsoft.AnalysisServices.SharePoint.Integration.DashboardLinksWebPart] from assembly [Microsoft.AnalysisServices.SharePoint.Integration, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91]) is referenced [1] times in the database [Sharepoint_80_Content_03], but is not installed on the current farm. Please install any feature/solution which contains this web part. One or more web parts are referenced in the database [Sharepoint_80_Content_03], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
[MissingWebPart] WebPart class [710dd8b1-df44-baec-3f85-84ef85658f95] (class [Microsoft.AnalysisServices.SharePoint.Integration.ReportsWebPart] from assembly [Microsoft.AnalysisServices.SharePoint.Integration, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91]) is referenced [1] times in the database [Sharepoint_80_Content_03], but is not installed on the current farm. Please install any feature/solution which contains this web part. One or more web parts are referenced in the database [Sharepoint_80_Content_03], but are not installed on the current farm. Please install any feature or solution which contains these web parts.

ROOT CAUSE:
These events are logged because the migrated SharePoint 2010 Sites contains some references to custom WebPart files and the linked feature/solution are not installed in the Farm.
In my case, I have tried to clean up the SharePoint 2007 Sites before the migration by disabling and uninstalling the unused features, but most of the times, the feature custom files are not getting removed correctly.

SOLUTION:
The easy solution is obviously to install the features/solution related to those webpart , but if you are in the same situation as me, you don't really need the webpart anymore and you just want the database to be clean and get rid of these events.

To safely remove the webparts and references, we need to be able to identify their specific location on the Farm, I have created an automated PowerShell script based on Phil's article (Thanks Phil), this script will get all the required information for you:

 param (
    [string]$DBserver = $(throw "Missing server name (please use -dbserver [dbserver])"),
    [string]$path = $(throw "Missing input file (please use -path [path\file.txt])")
)
 
#Set Variables
$input = @(Get-Content $path)
 
#Addin SharePoint2010 PowerShell Snapin
Add-PSSnapin -Name Microsoft.SharePoint.PowerShell
 
#Declare Log File
Function StartTracing
{
    $LogTime = Get-Date -Format yyyy-MM-dd_h-mm
    $script:LogFile = "MissingWebPartOutput-$LogTime.csv"
    Start-Transcript -Path $LogFile -Force
}
 
#Declare SQL Query function
function Run-SQLQuery ($SqlServer, $SqlDatabase, $SqlQuery)
{
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection
$SqlConnection.ConnectionString = "Server =" + $SqlServer + "; Database =" + $SqlDatabase + "; Integrated Security = True"
$SqlCmd = New-Object System.Data.SqlClient.SqlCommand
$SqlCmd.CommandText = $SqlQuery
$SqlCmd.Connection = $SqlConnection
$SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
$SqlAdapter.SelectCommand = $SqlCmd
$DataSet = New-Object System.Data.DataSet
$SqlAdapter.Fill($DataSet)
$SqlConnection.Close()
$DataSet.Tables[0]
}
 
 
function GetWebPartDetails ($wpid, $DBname)
    {
    #Define SQL Query and set in Variable
    $Query =  "SELECT * from AllDocs inner join AllWebParts on AllDocs.Id = AllWebParts.tp_PageUrlID where AllWebParts.tp_WebPartTypeID = '"+$wpid+"'"
 
    #Runing SQL Query to get information about Assembly (looking in EventReceiver Table) and store it in a Table
    $QueryReturn = @(Run-SQLQuery -SqlServer $DBserver -SqlDatabase $DBname -SqlQuery $Query | select Id, SiteId, DirName, LeafName, WebId, ListId, tp_ZoneID, tp_DisplayName)
 
    #Actions for each element in the table returned
        foreach ($event in $QueryReturn)
        {
            if ($event.id -ne $null)
                {
                #Get Site URL
                $site = Get-SPSite -Limit all | where {$_.Id -eq $event.SiteId}
    
                #Log information to Host
                Write-Host $wpid -nonewline -foregroundcolor yellow
                write-host ";" -nonewline
                write-host $site.Url -nonewline -foregroundcolor green
                write-host "/" -nonewline -foregroundcolor green
                write-host $event.LeafName -foregroundcolor green -nonewline
                write-host ";" -nonewline
                write-host $site.Url -nonewline -foregroundcolor gray
                write-host "/" -nonewline -foregroundcolor gray
                write-host $event.DirName -foregroundcolor gray -nonewline
                write-host "/" -nonewline -foregroundcolor gray
                write-host $event.LeafName -foregroundcolor gray -nonewline
                write-host "?contents=1" -foregroundcolor gray -nonewline
                write-host ";" -nonewline
                write-host $event.tp_ZoneID -foregroundcolor cyan
                }
         }
    }
 
#Start Logging
StartTracing
 
#Log the CVS Column Title Line
write-host "WebPartID;PageUrl;MaintenanceUrl;WpZoneID" -foregroundcolor Red
 
foreach ($event in $input)
    {
    $wpid = $event.split(";")[0]
    $DBname = $event.split(";")[1]
    GetWebPartDetails $wpid $dbname
    }
    
#Stop Logging
Stop-Transcript

Paste the above code in a PowerShellScript file, like [MissingWebPartDetails.ps1] and copy it on your local SharePoint Server Drive.

Launch the script from a Windows Powershell Cmd Prompt using the following parametters:
.\MissingWebPartDetails.ps1 -DBserver <SQLServerName> -path <fullpath\missingwebparts.txt>
[path\missingwebparts.txt] is a input file you need to create based on the [MissingWebPart] errors that you get on the SharePoint Health Analyzer

The input.txt file should be formated like this (WebPartId;ContentDatabase), example:

36f2680f-4855-f100-da5b-5dd1d07ae62b;Sharepoint_80_Content_01
d0d5a8f7-2e30-7cd0-276e-7cdc1aac9ab8;Sharepoint_80_Content_01
7dac9698-9043-eb31-b853-be8c1705512b;Sharepoint_80_Content_01
150b4681-ae25-d7be-bc71-1410062c7315;Sharepoint_80_Content_02
60085034-7d97-27c7-5823-2f941e6be1de;Sharepoint_80_Content_02
7a95935f-d524-5992-f505-809725b6a9e2;Sharepoint_80_Content_03
710dd8b1-df44-baec-3f85-84ef85658f95;Sharepoint_80_Content_03

After execution, the script generates a CSV output file in the same folder with details about the webpart location (PageUrl / MaintenanceUrl / Webpart Zone ID).

For [MissingSetupFile] events, please check my previous article
For [MissingAssembly] events, please check my previous article
For [MissingFeature] events, feel free to use the great tool FeatureAdmin, it can scan the whole farm and remove the corrupted feature references.

18 comments:

Anonymous said...

This is all well and good, but is there a way to remove these error webparts through PowerShell? At my client site they have 25 missing web parts in over 400 locations...

Anonymous said...

Really usefull this script.

Thanks!
Clem

Anonymous said...

Thanks a lot... Can you please provide the script to delete the webparts in same way?


A.D.

Anonymous said...

Scripts work fine, but at the mentioned pages and zones, there is not webpart to delete.
I think there are errors in my database, that cannot be solved by deleting the webparts....

Any solution for that?

Thanks!
Erik

Etienne said...

Hello Erik, maybe try from the WebPart Maintenance page:
In SharePoint, for any web part ASPX page if you append the querystring ?contents=1 then it automatically redirects to the web part maintenance page.

Anonymous said...

Thanx Etienne!

Anonymous said...

And if the web part is still not shown after the querystring "?contents=1" is used, then what? I have yet to get this deleted but on the test system I was able to directly delete from the DB. I know this is the wrong way but how else can this be done?

Khalid Ameerodien said...

If its not shown its probably a version of a page that is referencing the old webpart

swtjen01 said...

I LOVE this script! The only problem I have is that I have one aspx page that I can't view to remove. It is listed in the Pages library and shows the total items as 1 but I am not able to view it. Yes I am farm admin, site collection admin and everything under the sun.
when I go to the web part maintenance page the page won't load. The url error says the page doesn't exist. Not sure how to fix this error.

Khalid Ameerodien said...

Have you checked the site collection recyclebin? Sometimes the item will still be there.

Khushi said...

In my case the page itself doesn't exists. Should I remove records from the DB?

Unknown said...

Hi
How to delete the identified items , what is the command which i need to include in the script

Narasimha said...

How to identify the web part in the maintenance page. There is any way in the script to delete the item.

B said...

Hi Etienne,

I'm working through removing four web part errors that look to be orphaned references in the database. I've used several scripts out on the web to remove these entries and removed all version history of these pages(cleared both recycle bins). However these references are still occurring any thoughts on how I can permanently remove these entries?

jefrin said...

Great post very useful
SQL DBA training in chennai

AHMED said...



It has been simply incredibly generous with you to provide openly what exactly many individuals would’ve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted.
Data Science Course in Chennai | Best Data Science Training in Chennai
Python Course in Chennai | Best Python Training Course Institutes in Chennai
RPA Course in Chennai | RPA Course Training in Chennai
Digital Marketing Course in Chennai | Digital Marketing Course Training in Chennai

sheela rajesh said...

Wonderful blog!i really no words to thank you for giving an opportunity to read such kind of ideas.
Android Training in Chennai
app development course in chennai
JAVA Training in Chennai
Python Training in Chennai
Big data training in chennai
Selenium Training in Chennai
Android Training in Chennai
Android Training in Tambaram

jvimala said...

Amazing article. Your blog helped me to improve myself in many ways thanks for sharing this kind of wonderful informative blogs in live.
angularjs training in chennai | angularjs course in chennai | angularjs training institute in chennai | angularjs training institutes in chennai

Post a Comment