Missing features errors in current farm while working on cumulative updates

sns 9,236 Reputation points
2023-02-28T17:53:11.18+00:00

After patching upgrade that is after running psconfig command, With respect to few databases we are seeing errors like features are missing in the current farm , I want to eliminate those missing features from farm. Is there way to do it?

please suggest.

fyi:

We are not allowed to install any tool in the server to

Remove features

SharePoint Server
SharePoint Server
A family of Microsoft on-premises document management and storage systems.
2,374 questions
{count} votes

Accepted answer
  1. AllenXu-MSFT 21,046 Reputation points Microsoft Vendor
    2023-03-01T02:17:38.3933333+00:00

    Hi @sns,

    You can remove missing feature using 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  
        }  
    }  
      
    $contentDatabaseName = Read-Host "Enter the Content Datbase name:"  
    $featureId = Read-Host "Enter the feature Id :"  
      
    Remove-SPFeatureFromContentDB -ContentDB $contentDatabaseName -FeatureId $featureId –ReportOnly  
    
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.