One of my customers has a SharePoint 2013 farm with content migrated from SharePoint 2010.
In the past on SharePoint 2010 they have had the Microsoft SQL Server 2008 R2 Reporting Services-Add-In for SharePoint enabled on some sites. Because they did not need it any more they removed it from SharePoint but without deactivating the Report Server feature on each site collection.
Now on SharePoint 2013 this lead to problems with 3 orphaned content types:
- Report Builder Model
- Report Builder Report
- Report Data Source
First I tried to remove the corresponding feature “ReportServer” with ID e8389ec7-70fd-4179-a1c4-6fcb4342d7a0 from the site:
Get-SPFeature : Cannot find an Enabled Feature object with Id: e8389ec7-70fd-4179-a1c4-6fcb4342d7a0 in scope Site Url: https://sp2013.kc-dev.com/sites/reportingservices.
Than I tried to remove the content types manually using the web GUI and PowerShell. I got this errors:
and
Same message: “The content type “Report Builder Model” is part of an application feature.”
After reading some articles I found two propesed ways:
- Waldek Mastykarz: http://blog.mastykarz.nl/content-type-part-application-feature-error/
The solution there is to prevent this problem. – RIGHT!!!! – But for me it is too late. - The second (that I will not link here) said: The only way is to modify the content database directory. – NEVER EVER.
At last I found another way to get rid of the orphaned site collections.
In the following demo I use the content types of the Microsoft SQL Server 2008 R2 Reporting Services SharePoint Addon. I installed it on a SharePoint 2010 platform and created a site collection “https://sp2010.kc-dev.com/sites/reportingservices” in a seperate content database.
Than I migrated this content database to SharePoint 2013 including site collection upgrade. – New URL: https://sp2013.kc-dev.com/sites/reportingservices
Than I checked the usage of the content types using the static method GetUsage of Microsoft.SharePoint.SPContentTypeUsage.
In my case all 3 content types are used in a single list. It is necessary to remove each usage of each content type!! – In my case I deleted the list. After deletation it need to be removed from the recycle bin too!
… and also from the site collection recycle bin!
Now my site collection is clean. No results when checking the usage again:
After that I created a new folder in the FEATURES sub folder in the SharePoint hive:
Than I created the following script to create a dummy feature inside this folder. The dummy feature uses EXACLTY the same feature Id as the missing feature containing the orphaned content types.
Note #1: The feature ID is the same as for the original Reporting Services feature!
Note #2: For this content types it is necessary to remove the XmlDocuments tag and ist content. Otherwise the next step will fail.
With that script I took the cotnent type XML out of SharePoint into a elements.xml file.
Than I was able to install the feature using PowerShell:
At this point the missing feature is back in SharePoint. The system now will not moan if I deactivate the feature.
BEFORE deactivating I made a screenshot of the site content types page:
After this command…
… the site content types page looks like this:
The orphaned content types are gone!
Note: Maybe you get an error during deactivation saying the feature is not active at the scope. In this case you need to activate the feature first and deactivate it afterwards!
The last step is to remove the dummy feature:
That’s it.
Here you download the script if you like: http://bit.ly/OCToWx
Would this solution also work for SP 2010?
You saved my life 🙂 The best solution regarding this problem
Thanks. Your script helped me! Although the reason was in list template in my case. It prevented site CT from deleting. As soon as I’ve removed list template and deactivated the feature the problem content type is gone.
Can you please provide a link to the scripts – the one you have right now is not currently working.
Where is the script? I can’t find it on your site, nor am I seeing it on Codeplex.
Can you please share script again? the link was dead, My case is migrated from SP2013 to SP2019 that have no SSRS anymore
We did the same thing. Migrated from 2013 to 2019 and had those content types all over the place. Here is what I did.
Created one file that created the dummy feature and a separate one that went through all sites and enabled and disabled the feature. You do need to create the feature subfolder and at the end uninstall the feature.
*******************Feature Creator Begin**************
@”
“@ | Set-Content “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\TEMPLATE\FEATURES\dagtemp\feature.xml” -Encoding UTF8
$elements = @”
“@
$site = Get-SPSite https://SomeURLWithTheOrphanedCTs
$web = $site.RootWeb
$ct1 = $web.ContentTypes | ? { $_.id -eq “0x0101007DFDDF56F8A9492DAA9366B83A95B3A0” }
$ct2 = $web.ContentTypes | ? { $_.id -eq “0x010100C3676CDFA2F24E1D949A8BF2B06F6B8B” }
$ct3 = $web.ContentTypes | ? { $_.id -eq “0x010100D8704AF8ED734F4088724751E0F2727D” }
$ct1, $ct2, $ct3 | % {
$xml = [xml]$_.SchemaXmlWithResourceTokens
$remove = $xml.SelectSingleNode(“//XmlDocuments”)
$remove.ParentNode.removechild($remove)
$elements += $xml.OuterXml
}
$elements += @”
“@
$elements | set-content “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\TEMPLATE\FEATURES\dagtemp\dummycontenttypes.xml” -encoding UTF8
*******************Feature Creator End**************
*******************Clean up script Begin**************
#Get All Site Collections in the web application
Start-Transcript -Path “c:\temp\ctcleanup.txt” -Force
Get-SPSite -Limit ALL | Get-SPWeb -Limit All | ForEach-Object {
$web = $_
write-host “Scaning Site” $_.title “@” $_.URL
$ctchk = $null
$ctchk = $web.ContentTypes | ? { $_.id -eq “0x0101007DFDDF56F8A9492DAA9366B83A95B3A0” }
if($ctchk.name -ne $Null)
{
write-host “Cleaning Content Types ” $_.title “@” $_.URL
Get-SPFeature “e8389ec7-70fd-4179-a1c4-6fcb4342d7a0” | enable-spfeature -Url $web.url -verbose
Get-SPFeature “e8389ec7-70fd-4179-a1c4-6fcb4342d7a0” | disable-spfeature -Url $web.url -verbose -Confirm:$false
}
}
Stop-Transcript
*******************Clean up script End**************