Simple PowerShell Commands to find the Orphan Objects

To get the orphan objects on the specific content database please execute the below commands:

  1. $CDB = Get-SPContentDatabase -identity "GUID of the content database"  
  2. $CDB.Repair($false) # $false to return the orphan objects  
In order to clean the orphan objects, execute the below command:
  1. $CDB.repair($true)  
To get the GUID of specific content database attached to a web application, execute below commands:
  1. $dbs = get-spwebapplication "Webapplication URL"  
  2. $dbs.ContentDatabases  
Now you will get list of content databases attached to the web application and its details. Grab the content database ID from here and use it in your command.
Ebook Download
View all
Learn
View all