When we redeploy wsp files in sharepoint server, it will check for its previous version using the feature ID. The old versions feature id will not be available since wsp files has been removed. Though the files have been removed its id will be available in the server.
It will throw an exception and this exception will be stored in the configuration section. When site content backup is restored this error transfers to the other server too. This exceptions can be removed by using power shell command.
Go to the following location. Central Administration --> Monitoring --> Review Problems and Solutions under Health Analyzer. Under category configuration click Missing Server side dependencies. There you will find [Missing Feature] type. Now go to Sharepoint Power Shell. and do the following.
PowerShell
Remove Features in SharePoint because of Health Issue For "Missing
Feature"
Run The below power shell Method in SharePoint Management
shell.
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
}
}
To run only a report (-ReportOnly property):
Remove-SPFeatureFromContentDB -ContentDB "Content_DBName" -FeatureId "e8389ec7-70fd-4179-a1c4-6fcb4342d7a0" –ReportOnly
To remove the feature from all sites, site collections in the db run (no -ReportOnly property):
Remove-SPFeatureFromContentDB -ContentDB "Content_DBName" -FeatureId "8096285f-1473-45c7-85b7-f745e5b2cf29"
This will work only for [Missing Feature] issues.
No comments:
Post a Comment