Test-SPContentDatabase: Fix MissingWebPart Issue in SharePoint 2013 Migration
Problem: MissingWebPart Issues when running Test-SPContentDatabase cmdlet on SharePoint content database during SharePoint 2013 migration project.
Category : MissingWebPart
Error : True
UpgradeBlocking : False
Message : WebPart class [9a43cf43-4500-d748-6385-09e622f28c01] is referenced [3] times in the database [WSS_Content_Database], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy : One or more web parts are referenced in the database [WSS_Content_Database], but are not installed on the current farm. Please install any feature or solution which contains these web parts.
Root cause: MissingWebPart issue is because, the migrated SharePoint 2013 sites contains references to custom Web Parts which are not installed in the target Farm.
Solution:
Install & deploy the solution package (WSP) which contains the webpart to your new SharePoint 2013 farm to fix this issue! Well, that wouldn't be a case always, What if you don't really need the webpart anymore in your SharePoint and want to get rid it?
Find all pages referring the Web Part using PowerShell:
Use this PowerShell script to find all pages which are using the particular web part in your environment.
How to Delete Web Part from SharePoint Page?
So you decided that the web part is no longer necessary and want to remove the web part from page? Well:
Remember, as Microsoft says, even reading from SharePoint content databases isn't supported, use this PowerShell script to get all locations where a particular web part is being used. PowerShell to find the web part's usage in SharePoint
Category : MissingWebPart
Error : True
UpgradeBlocking : False
Message : WebPart class [9a43cf43-4500-d748-6385-09e622f28c01] is referenced [3] times in the database [WSS_Content_Database], but is not installed on the current farm. Please install any feature/solution which contains this web part.
Remedy : One or more web parts are referenced in the database [WSS_Content_Database], but are not installed on the current farm. Please install any feature or solution which contains these web parts.

Root cause: MissingWebPart issue is because, the migrated SharePoint 2013 sites contains references to custom Web Parts which are not installed in the target Farm.
Solution:
Install & deploy the solution package (WSP) which contains the webpart to your new SharePoint 2013 farm to fix this issue! Well, that wouldn't be a case always, What if you don't really need the webpart anymore in your SharePoint and want to get rid it?
Find all pages referring the Web Part using PowerShell:
Use this PowerShell script to find all pages which are using the particular web part in your environment.
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue Function Run-SQLScript($SQLServer, $SQLDatabase, $SQLQuery) { $ConnectionString = "Server =" + $SQLServer + "; Database =" + $SQLDatabase + "; Integrated Security = True" $Connection = new-object system.data.SqlClient.SQLConnection($ConnectionString) $Command = new-object system.data.sqlclient.sqlcommand($SQLQuery,$Connection) $Connection.Open() $Adapter = New-Object System.Data.sqlclient.sqlDataAdapter $Command $Dataset = New-Object System.Data.DataSet $Adapter.Fill($Dataset) $Connection.Close() $Dataset.Tables[0] } #Define configuration parameters $Database="WSS_Content_KM" $webPartID="90F70A36-4EC6-167D-792C-31B7EA83201B" #Get the Database Server from Database $server = (Get-SPDatabase |?{ $_.name -eq $Database}).server #Query SQL Server content Database to get information about the MissingFiles $Query = "SELECT distinct ID,SiteId,DirName, LeafName, WebId, ListId from dbo.AllDocs where id in (select tp_PageUrlID from dbo.AllWebParts where tp_WebPartTypeId ='$($webPartID)')" $QueryResults = Run-SQLScript -SQLServer $Server -SQLDatabase $Database -SQLQuery $Query | select Id , SiteId, DirName, LeafName, WebId, ListId #Iterate through results foreach ($Result in $QueryResults) { if($Result.id -ne $Null) { $Site = Get-SPSite -Limit all | where { $_.Id -eq $Result.SiteId } $Web = $Site | Get-SPWeb -Limit all | where { $_.Id -eq $Result.WebId } #Get the URL of the file which is referring the web part $File = $web.GetFile([Guid]$Result.Id) write-host "$($Web.URL)/$($File.Url)" -foregroundcolor green } }This script gets you the list of pages where the missing web part is being referenced from.
How to Delete Web Part from SharePoint Page?
So you decided that the web part is no longer necessary and want to remove the web part from page? Well:
- Get into WebPart Maintenance page by appending the query string "?contents=1" to the URL
- In the web part maintenance page, Select and delete the unwanted web part!
Remember, as Microsoft says, even reading from SharePoint content databases isn't supported, use this PowerShell script to get all locations where a particular web part is being used. PowerShell to find the web part's usage in SharePoint
thank you for the script
ReplyDeletereplace the $Server="Ab-SQL-001" with $server = (Get-SPDatabase |?{ $_.name -eq $Database}).server
Yeah.. That helps to remove Hard-coded server name! Thanks, Henrik!!
Delete