Fix MissingSetupFile Error of Test-SPContentDatabase in SharePoint Migration

Getting “MissingSetupFile” errors when you run the “Test-SPContentDataBase” cmdlet on SharePoint content databases during a migration process.
[MissingSetupFile] File [Features\Feature-folder\feature-artifact] is referenced [1] times in the database [SharePoint_Content_database], 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 [SharePoint_Content_database], but are not installed on the current farm. Please install any feature or solution which contains these files.
fix sharepoint test-spcontentdatabase missingsetupfile error
Root Cause:
In SharePoint migration, The source SharePoint 2010 environment sites contain references to some of the Feature files, and those features are not installed in the target SharePoint 2013 Farm.


Well, The resolution is: Install & Deploy all solutions from the source farm to the destination farm. Your organization may have built & deployed several customizations such as 3rd party products (such as bamboo solutions), custom WSP solutions, site definitions, Features, event receivers, Web Parts, user controls, etc., in the SharePoint 2010 environment. You have to install and deploy all these binaries & solutions to your destination SharePoint 2013 environment before testing content databases for an upgrade.

Deploy Solutions from Source Farm to the Destination farm:

  • Go to SharePoint Central Administration >> Navigate to “Solution Management” >> Manage Farm Solutions from System Settings of your SharePoint 2010 Farm (or any SharePoint source farm).
  • Make an inventory of all your WSP Solutions deployed to the farm. Identify the Web Applications to which these solutions are deployed to.
  • Download all WSP files and port it to the target farm. Deploy all of them in the target as per the source farm.

Instead of manually doing the above steps, you can use PowerShell to automate:

  1. How to Extract & Download All WSP Solution Files in SharePoint
  2. How to Install & Deploy Multiple WSP Solutions using PowerShell in SharePoint

What if you don’t need those missing feature artifacts such as web parts in your Target farm and cleanup missing setup files from the content database?

PowerShell script to find & delete missing setup files:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

Function Run-SQLScript($SQLServer, $SQLDatabase, $SQLQuery)
    $ConnectionString = "Server =" + $SQLServer + "; Database =" + $SQLDatabase + "; Integrated Security = True"
    $Connection = new-object$ConnectionString)
    $Command = new-object$SQLQuery,$Connection)
    $Adapter = New-Object System.Data.sqlclient.sqlDataAdapter $Command
    $Dataset = New-Object System.Data.DataSet

#Define configuration parameters

#Query SQL Server content Database to get information about the MissingFiles
$Query = "SELECT * from AllDocs where SetupPath like '"+$SetupFile+"'"
$QueryResults = @(Run-SQLScript -SQLServer $Server -SQLDatabase $Database -SQLQuery $Query | select Id, SiteId, WebId)

#Iterate through results
foreach ($Result in $QueryResults)
    if($ -ne $Null)
        $Site = Get-SPSite -Limit all | where { $_.Id -eq $Result.SiteId }
        $Web = $Site | Get-SPWeb -Limit all | where { $_.Id -eq $Result.WebId }

        #Get the URL of the file which is referring the feature
        $File = $web.GetFile([Guid]$Result.Id)
        write-host "$($Web.URL)/$($File.Url)" -foregroundcolor green

This script gets you all locations where the missing setup file is referenced (and optionally delete them!). Don’t forget to set the variables $Server, $Database, and $SetupFile appropriately!

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

2 thoughts on “Fix MissingSetupFile Error of Test-SPContentDatabase in SharePoint Migration

  • Hello,
    When I tried to delete the file I got the message below

    Exception calling “Delete” with “0” argument(s): “System.NullReferenceException: Object reference not set to an instance of an object.
    at Microsoft.SharePoint.WorkflowServices.WorkflowDefinitionStorageEventReceiver.ItemDeleting(SPItemEventProperties properties)”
    At line:1 char: 1

    CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    FullyQualifiedErrorId : SPException

    Can you help me to resolve this error?
    Thank you

  • $File = $web.GetFile([Guid]$Result.Id) // Error on this line
    At this line i am getting this Error: You cannot call a method on a NULL valued expression
    + categotyInfo InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId: InvikeMethodOnNull

    I can see GUID value of $Result.Id using write-host

    What’s wrong ?


Leave a Reply