Missing server side dependencies in SharePoint 2013

The follow issues in Health Analyzer:

[MissingWebPart]

WebPart class [40209021-7bb0-e465-2576-abddac43061b] (class [CommunityForumTopics.WebParts.ForumTopicsWebPart.ForumTopicsWebPart] from assembly [CommunityForumTopics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=4e4625abaca6859d]) is referenced [73] times in the database [WSS_Content], 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 [WSS_Content], but are not installed on the current farm. Please install any feature or solution which contains these web parts.

[MissingSetupFile]

File [Features\image\GoToTop_normal_icon.png] is referenced [1] times in the database [WSS_Content], but is not installed on the current farm. Please install any feature/solution which contains this file. One or more setup files are referenced in the database [WSS_Content], but are not installed on the current farm. Please install any feature or solution which contains these files.

[MissingFeature]

Database [WSS_Content] has reference(s) to a missing feature: Id = [8096285f-1463-42c7-82b7-f745e5bacf29], Name = [My Feature], Description = [], Install Location = [Test-MyFeature]. The feature with Id 8096285f-1463-42c7-82b7-f745e5bacf29 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.

How to fix it?[MissingFeature]

Note: This message reports a content database name and feature ID ,,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.

The following PowerShell script will interrogate a specified content database and feature ID and do two things:

Produce a report in the PowerShell console showing which sites or site collections contain the offending feature.Forcibly deactivate the feature from the applicable sites or site collections.function Remove-SPFeatureFromContentDB($ContentDb, $FeatureId, [switch]$ReportOnly){$db = Get-SPDatabase | where { $_.Name -eq $ContentDb }[bool]$report = $falseif ($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}else{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}} # it will find the feature Remove-SPFeatureFromContentDB -ContentDB "WSS_Content" -FeatureId "<span style="color:#3366ff;">8096285f-1463-42c7-82b7-f745e5bacf29</span>" -ReportOnly # it will remove the feature directly Remove-SPFeatureFromContentDB -ContentDB "WSS_Content" -FeatureId "<span style="color:#3366ff;">8096285f-1463-42c7-82b7-f745e5bacf29</span>"

[MissingWebPart]

Note: These events are logged because the migrated SharePoint Sites contains some references to custom WebPart files and the linked feature/solution are not installed in the Farm

To safely remove the webparts and references, we need to be able to identify their specific location on the Farm

# the name of the Db server$DBserver = "tristan-db"#<strong>[path\missingwebparts.txt]</strong> is a input file you need to create based on the <strong>[MissingWebPart]</strong> errors that you get on the SharePoint Health Analyzer$path = "C:\Users\tristan-desktop\Script\MissingHealth.txt" #Set Variables$input = @(Get-Content $path) #Declare Log FileFunction StartTracing{$LogTime = Get-Date -Format yyyy-MM-dd_h-mm$script:LogFile = "MissingWebPartOutput-$LogTime.csv"Start-Transcript -Path $LogFile -Force} #Declare SQL Query functionfunction 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 returnedforeach ($event in $QueryReturn){if ($event.id -ne $null){#Get Site URL$site = Get-SPSite -Limit all | where {$_.Id -eq $event.SiteId}write-host "==================================================================="write-host $site.Url -nonewline -foregroundcolor greenwrite-host "/" $event.DirName -nonewline -foregroundcolor greenwrite-host "/"$event.LeafName -foregroundcolor green}}} 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

run the cmd:

1. it will found ou all the relevant pags implemented the webpart

2. then you need to delete the webpart in the exactly page one by one by manual

3. clear the history version of the page

4. finally, remember to clear the recycle bin

you can run the cmd again to check the result, it will not find the same issues.

[MissingSetFile]

Note: These events are logged because the migrated SharePoint 2013 Sites contains some references to custom Feature files and the linked feature are not installed in the Farm.

记忆的屏障,曾经心动的声音已渐渐远去。

Missing server side dependencies in SharePoint 2013

相关文章:

你感兴趣的文章:

标签云: