Cannot delete missingsetupfile with powershell

Philippe NONORGUES 26 Reputation points
2021-04-20T07:08:57.48+00:00

Hello,

I had a missingsetupfile error in SharePoint 2019.

I got Id, SiteId and Web Id from SQL and used PowerShell script to get the file url, but when I ran $file.delete() I got the message below :
89425-missingsetupfile-delete-error.jpg

I saw folder and xaml file in storman.aspx page, but not in site menu or site content.
Can you help me to resolve this error?

Thank you.

SharePoint Server Management
SharePoint Server Management
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Management: The act or process of organizing, handling, directing or controlling something.
2,885 questions
{count} votes

2 answers

Sort by: Most helpful
  1. JoyZ 18,056 Reputation points
    2021-04-21T08:05:37.58+00:00

    Hi @Philippe NONORGUES ,

    Per my test, I could delete the workflow.xaml file successfully using following powershell:

    $web = get-spweb -Identity http://sp13:xxxxx  
    $file = $web.getfile("wfsvc/3bcdc4256c604385b73fa92852a4aaa2/workflow.xaml")  
    $file.delete()  
    

    From your error message, it seems that the file doesn't exist in the site collection.

    Try to run sharepoint powershell as administrator to compare the result.
    89776-image.png
    Another question, why not delete the workflow directly in SharePoint Designer?


    If an Answer is helpful, please click "Accept Answer" and upvote it.

    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.


  2. JoyZ 18,056 Reputation points
    2021-04-28T08:12:13.697+00:00

    @Philippe NONORGUES ,

    Use a SQL query to find the location of the missing setup file and then a Window PowerShell script to remove the file reference from SharePoint Sever.

    To reduce the risk of locking or other performance issues it is preferable to run these queries should be against backup copy or snapshot of the database.

    SQL sample for listing setup file information:

    USE SP_ContentPortal(backup or snapshot)  
    SELECT id, SiteID, DirName, LeafName, WebId, ListId  
    FROM AllDocs (NOLOCK) where SetupPath = 'Features\BCEE.recettage....\Workflow.xaml'  
    

    PowerShell sample for removing setup files by ID:

    #File Information  
    $setupFileID = "xxx"  
    $siteID = "xxx"  
    $WebID = "xxx"  
    #Get file  
    $site = Get-SPSite -Identity $siteID  
    $web = Get-SPWeb -Identity $WebID -Site $siteID  
    $file = $web.GetFile([GUID]$setupFileID)  
    #Report on location  
    $filelocation = "{0}{1}" -f ($site.WebApplication.Url).TrimEnd("/"), $file.ServerRelativeUrl  
    Write-Host "Found file location:" $filelocation  
    #Delete the file, the Delete() method bypasses the recycle bin  
    $file.Delete()  
    $web.dispose()  
    $site.dispose()  
    

    More information for your reference:

    https://sharepointhelpmm.wordpress.com/2018/05/08/post-upgrade-cleanup-missing-server-side-dependencies/

    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.


    If an Answer is helpful, please click "Accept Answer" and upvote it.

    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.