[MissingFeature] Database [SharePoint_Content] has reference(s) to a missing
阿新 • • 發佈:2019-01-26
原文參見:http://get-spscripts.com/2011/06/removing-features-from-content-database.html
Error Message:
從錯誤資訊中可以看出,名為“SharePoint_Content_Portal”的資料庫中的一個feature,並沒有安裝在SharePoint farm中或者曾經安裝過,但是已經被移除了。通常情況下,在移除solution的時候,會自動禁用feature,然後再移除solution,但是有些情況下,移除得並不乾淨,例如web application 級別的feature,或者沒有移除自定義的event receiver或者webpart等等。[MissingFeature] Database [SharePoint_Content_Portal] 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 [SharePoint_Content_Portal], 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.
下面的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 } 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 } }
有兩種方法使用以上程式碼,
1. 如果你只是想查詢哪些站點或者站點集中包含缺失的feature,使用如下方法:
Remove-SPFeatureFromContentDB -ContentDB "SharePoint_Content_Portal" -FeatureId "8096285f-1463-42c7-82b7-f745e5bacf29" –ReportOnly
這個方法會遍歷所有的站點,列出類似以下的內容:Feature found in site : http://portal/site
2. 如果你想從資料庫中移除缺失的feature,可以使用下面的方法:
這個方法會輸出類似如下的資訊:Remove-SPFeatureFromContentDB -ContentDB "SharePoint_Content_Portal" -FeatureId "8096285f-1463-42c7-82b7-f745e5bacf29"
Feature successfully removed from site : http://portal/site