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:

  1. Produce a report in the PowerShell console showing which sites or site collections contain the offending feature.
  2. 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 = $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
    }

}

 # 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 File
Function StartTracing
{
    $LogTime = Get-Date -Format yyyy-MM-dd_h-mm
    $script:LogFile = "MissingWebPartOutput-$LogTime.csv"
    Start-Transcript -Path $LogFile -Force
}

#Declare SQL Query function
function 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 returned
        foreach ($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 green
                write-host "/" $event.DirName -nonewline -foregroundcolor green
                write-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.

The easy solution is obviously to install the features related to those files, but if you are in the same situation as me, you don‘t really need the features anymore and you just want the database to be clean and get rid of these events.

 DBserver = "tristan-db"
 $path = "C:\Users\Script\MissingHealth_Set.txt"

 #Set Variables
 $input = @(Get-Content $path)
 #Addin SharePoint2010 PowerShell Snapin
 Add-PSSnapin -Name Microsoft.SharePoint.PowerShell
 #Declare Log File
 Function StartTracing
 {
   $LogTime = Get-Date -Format yyyy-MM-dd_h-mm
   $script:LogFile = "MissingSetupFileOutput-$LogTime.txt"
   Start-Transcript -Path $LogFile -Force
 }
 #Declare SQL Query function
 function 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]
 }
 #Declare the GetFileUrl function
 function GetFileUrl ($filepath, $DBname)
 {
     #Define SQL Query and set in Variable
     $Query = "SELECT * from AllDocs where SetupPath = '"+$filepath+"'"
     #Runing SQL Query to get information about the MissingFiles and store it in a Table
     $QueryReturn = @(Run-SQLQuery -SqlServer $DBserver -SqlDatabase $DBname -SqlQuery $Query | select Id, SiteId, DirName, LeafName, WebId, ListId)
     foreach ($event in $QueryReturn)
       {
         if ($event.id -ne $null)
         {
         $site = Get-SPSite -Limit all | where { $_.Id -eq $event.SiteId }
         #get the URL of the Web:
         $web = $site | Get-SPWeb -Limit all | where { $_.Id -eq $event.WebId }
         #Write the SPWeb URL to host
         Write-Host $filepath -nonewline -foregroundcolor yellow
         Write-Host ";" -nonewline
         write-host $web.Url -NoNewline -foregroundcolor green
         #get the URL of the actual file:
         $file = $web.GetFile([Guid]$event.Id)
         #Write the relative URL to host
         write-host "/" -nonewline -foregroundcolor green
         write-host $file.Url -foregroundcolor green
         #$file.delete()  # you can delete the file with this code
         }
       }
 }
 #Start Logging
 StartTracing
 #Log the CVS Column Title Line
 write-host "MissingSetupFile;Url" -foregroundcolor Red
 foreach ($event in $input)
   {
   $filepath = $event.split(";")[0]
   $DBname = $event.split(";")[1]
   #call Function
   GetFileUrl $filepath $dbname
   }
 #Stop Logging
 Stop-Transcript

Note: If you want to get rid of all files unused, update the above script by adding the line
$file.delete() after the line write-host $file.Url -foregroundcolor green 
in the IF statement

(to be used at your own risk - I would strongly recommend to first analyse the report generated before updating the script with the delete option, to avoid removing important files.)

More in detail : http://etienne-sharepoint.blogspot.jp/2011/10/solving-missingsetupfile-errors-from.html,
http://get-spscripts.com/2011/06/removing-features-from-content-database.html



时间: 2024-08-01 20:41:25

Missing server side dependencies in SharePoint 2013的相关文章

在使用SQL server High Availability 的SharePoint 2013 Farm环境中使用Import-SPMetadataWebServicePartitionData

本文讲述笔者在在使用SQL server High Availability 的SharePoint 2013 Farm环境中使用Import-SPMetadataWebServicePartitionData遇到的问题,希望对大家有帮助. 笔者最近使用Export-SPMetadataWebServicePartitionData 从开发环境导出Metadata ,然后使用Import-SPMetadataWebServicePartitionData将Metadata 备份文件导入到使用SQ

SharePoint 2013 Power Pivot 安装详细说明(图解)

SharePoint 2013 Power Pivot 安装配置详细说明 前提必要条件,SharePoint 2013 为企业版本,已经安装成功.数据库为SQL Server BI 或企业版本. 一,安装 1,打开SQLServer 2014  企业版 安装程序 开始安装. 选择安装--全新SQL Server 独立安装或向现有安装添加功能. 选中SQL Server PowerPivot for SharePoint 如下图. 然后下一步,默认实例.如下图 录入账号和密码 下一步,数据库引擎配

SharePoint 2013 安装配置(3-1)

在第二部分中,我向您展示了如何在Windows Server 2012 R2 for SharePoint 2013上设置Active Directory域服务.现在我们应该能够在Active Directory中设置管理员和服务帐户. 第三部分,我将逐步介绍在Windows Server 2012 R2上安装Microsoft SQL Server 2012.我将创建一个可用于存储SharePoint 2013数据的SQL Server的默认实例. 必要条件 添加SQL 管理服务账号 Fram

如何在SharePoint 2013 创建Power pivot 库(How to create a PowerPivot Gallery )及错误解决方法

如何在SharePoint 2013 创建Power pivot 库(How to create a PowerPivot Gallery ) 为了这样一个功能 浪费我一个上午的时间. 需求是在SharePoint2013 的环境上创建一个Power Point 库. 1,打开网站--网站设置--网站集管理--网站集功能. 激活 power pivot 网站集功能 如果找不到,英文版是 这里注意,如果没有这项就要重新配置power pivot 我的时间 就是浪费在这里的.  1.单击"开始&qu

在Windows Server 2012 R2上安装SharePoint 2013 with SP1失败,提示没有.net4.5的解决办法

现在的Server用Windows Server 2012 R2的越来越多了,在部署带Sp1的SharePoint2013的时候,走完预安装工具后,点击setup提示缺少.net4.5. 其实Windows Server 2012 R2打完所有更新补丁后,操作系统的.net版本已经是4.6.1了,因为.net4.6是os的组件的一部分,所以无法直接卸载,也不能单独去手工安装.net4.5安装包. 通过dotnetfx_cleanup_tool 卸载失败了. 2种解决办法: a. 修改注册表: 1

sharepoint 2013 更改搜索server组态

1.新搜索server在.安装sharepoint server 2013,并连接到一个现有的sharepoint server领域,完成后.您可以配置新的搜索server. 打开sharepoint powershell 2013 : $hostA = Get-SPEnterpriseSearchServiceInstance -Identity "DevSearch2013" Start-SPEnterpriseSearchServiceInstance -Identity $ho

SharePoint 2013 安装和配置 Project Server 2013

如何在SharePoint Server 2013 服务器场中安装 Project Server 2013 并创建 Project Server Service 应用程序. 第一步:安装 Project Server 2013 安装会吧  就不多啰嗦了.  第二部 :运行 SharePoint 产品和技术配置向导 依次单击"开始"."所有程序"."Microsoft SharePoint 2013 产品"和"SharePoint 201

如何在Windows Server 2012 R2上安装SharePoint 2013

笔者原以为是个挺容易个事儿, 毕竟是微软自家的产品安装在自家的操作系统上, 没想到还是让我费了半天劲. 写在这里吧, 方便其他的朋友. 具体步骤 ============================== 1. 准备好Windows Server 2012 R2 RTM的一台虚拟机, 准备SharePoint 2013 RTM的安装包, 和SP1的安装包. 2. 制作slipstream安装文件, 参考这里. 3. 这时运行prerequisiteinstaller会如下的报错. 4. 先在S

SharePoint 2013 中的SQL Server 安全

使用SharePoint很长时间以来,都认为Sql只需要最初始的配置,即不再需要管理和维护:而事实上,Sql的管理和安全,都是和SharePoint环境的稳定性息息相关的,所以,要绝对重视SharePoint中Sql Server的管理和维护. 本文主要介绍的有以下三点: 一.关于Sql账号的权限: 二.关于Sql Server的磁盘管理 三.关于Sql Server服务端口的修改 一.关于Sql账号的权限 首先,要说的就是关于账号的问题,无论是SharePoint服务器场配置账号,还是各种服务