The following script identifies detailed Orphaned objects in a SharePoint farm, and outputs them in a XML file.
Get-SPContentDatabase | ForEach-Object { $_.repair($false) | out-file -filePath (“x:\temp\” + $_.name + “.xml”)}
With only a small change all orphaned objects are deleted, and also output into a XML file.
Get-SPContentDatabase | ForEach-Object { $_.repair($true) | out-file -filePath (“x:\temp\” + $_.name + “.xml”)}