Content Type Hub - Cannot delete content type

%3CLINGO-SUB%20id%3D%22lingo-sub-2074486%22%20slang%3D%22en-US%22%3EContent%20Type%20Hub%20-%20Cannot%20delete%20content%20type%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2074486%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGuess%20this%20has%20been%20discussed%20many%20time%20and%20I%20have%20tried%20all%20different%20things%20without%20success.%20Have%20also%20an%20open%20ticket%20with%20Microsoft%20whom%20are%20just%20sending%20references%20to%20public%20docs%20which%20is%20not%20helpful.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMy%20issue%3A%3C%2FP%3E%3CP%3ECannot%20delete%20a%20Content%20Type%20(CT)%20from%20the%20Content%20Type%20Hub%20via%20the%20SPO%20Admin%20Center%20with%20the%20error%20that%20it%20is%20still%20in%20use.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20I%20have%20done%3A%3C%2FP%3E%3COL%3E%3CLI%3EI%20have%20tried%20to%20publish%20the%20CT%2C%20wait%20for%20%2B8h%20and%20then%20unpublish%20it%20and%20wait%20another%204-8h%20before%20trying%20to%20delete%20it.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLI%3E%3CLI%3EHave%20emptied%20the%20primary%20and%20secondary%20recycle%20bin%20for%20each%20site%20in%20the%20tenant%20using%20PnP%3C%2FLI%3E%3C%2FOL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3EClear-PnPRecycleBinItem%20-All%20-Force%E2%80%8B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E3.%20Via%20code%20trying%20to%20find%20the%20content%20type%20and%20having%20it%20removed.%20Below%20code%20is%20currently%20saying%20that%20the%20CT%20with%20a%20specific%20ID%20is%20not%20found%20on%20any%20site.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3Efunction%20FindContentTypeById%20%7B%0A%20%20%20%20param%20(%0A%20%20%20%20%20%20%20%20%5BParameter(Mandatory%3D%24true)%5D%0A%20%20%20%20%20%20%20%20%5Bstring%5D%24ContentTypeId%20%20%20%20%20%20%20%20%0A%20%20%20%20)%0A%20%20%20%20%23%23%20Get%20all%20sites%20in%20the%20tenant%0A%20%20%20%20%24siteCollections%20%3D%20GetSites%0A%20%20%20%20%0A%20%20%20%20foreach%20(%24site%20in%20%24siteCollections)%20%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%24siteUrl%20%3D%20%24(%24site.Url)%0A%20%20%20%20%20%20%20%20Write-Host%20%22%2B%20Site%3A%20%24siteUrl%22%0A%20%20%20%20%20%20%20%20ConnectPnPOnline%20-Url%20%24siteUrl%0A%0A%20%20%20%20%20%20%20%20%24lists%20%3D%20Get-PnPList%0A%20%20%20%20%20%20%20%20foreach%20(%24list%20in%20%24lists)%20%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%24ct%20%3D%20Get-PnPContentType%20-List%20%24(%24list.Title)%20-Identity%20%24ContentTypeId%20-ErrorAction%20SilentlyContinue%0A%20%20%20%20%20%20%20%20%20%20%20%20if(%24null%20-ne%20%24ct)%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Write-Host%20-ForegroundColor%20Yellow%20%22%20%20%20%20-%20Found%20CT%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Write-Host%20-ForegroundColor%20Yellow%20%22%20%20%20%20%20%20-%20Found%3A%20%24(%24ct.Name)%20in%20List%3A%20%24(%24list.Title)%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20%24siteCTs%20%3D%20Get-PnPContentType%0A%0A%20%20%20%20%20%20%20%20%24x%20%3D%20%24siteCTs%20%7C%20Where-Object%20%7B((%24_.Id).StringValue%20-eq%20(%24findCT))%7D%0A%20%20%20%20%20%20%20%20if(%24null%20-ne%20%24x)%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20Write-Host%20%22%20%20-%20Found%3A%20%24(%24x.Name)%20in%20(%24site.Url)%22%0A%20%20%20%20%20%20%20%20%7D%0A%0A%20%20%20%20%20%20%20%20Disconnect-PnPOnline%0A%20%20%20%20%7D%0A%7D%E2%80%8B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EI%20have%20also%20run%20code%20that%20looks%20for%20a%20Content%20Type%20by%20Name%20with%20the%20same%20result%20(not%20found).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%2C%20any%20ideas%20what%20else%20I%20could%20do%2Ftry%20to%20have%20the%20CT%20deleted%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20CT%20Hub%20is%20in%20need%20of%20major%20improvements%20to%20better%20support%20SPO.%20Implementation%20of%20better%20logging%2Fauditing%20capability%20(tracking%20down%20what%20site%2Flist%2Fitem%20is%20restricting%20deletion)%20and%20better%20provisioning%20functionality%20are%20some.%20As%20of%20now%20the%20CT%20Hub%20is%20a%20loose%20canon%20causing%20lot%20of%20headaches%20and%20instead%20of%20using%20it%20I'm%20avoiding%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%2FAdam%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2074486%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EContent%20Type%20Hub%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%20Online%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional Contributor

Hi,

 

Guess this has been discussed many time and I have tried all different things without success. Have also an open ticket with Microsoft whom are just sending references to public docs which is not helpful.

 

My issue:

Cannot delete a Content Type (CT) from the Content Type Hub via the SPO Admin Center with the error that it is still in use.

 

What I have done:

  1. I have tried to publish the CT, wait for +8h and then unpublish it and wait another 4-8h before trying to delete it.

  2. Have emptied the primary and secondary recycle bin for each site in the tenant using PnP

 

Clear-PnPRecycleBinItem -All -Force​

 

 

3. Via code trying to find the content type and having it removed. Below code is currently saying that the CT with a specific ID is not found on any site.

 

function FindContentTypeById {
    param (
        [Parameter(Mandatory=$true)]
        [string]$ContentTypeId        
    )
    ## Get all sites in the tenant
    $siteCollections = GetSites
    
    foreach ($site in $siteCollections) 
    {
        $siteUrl = $($site.Url)
        Write-Host "+ Site: $siteUrl"
        ConnectPnPOnline -Url $siteUrl

        $lists = Get-PnPList
        foreach ($list in $lists) 
        {
            $ct = Get-PnPContentType -List $($list.Title) -Identity $ContentTypeId -ErrorAction SilentlyContinue
            if($null -ne $ct) {
                Write-Host -ForegroundColor Yellow "    - Found CT"
                Write-Host -ForegroundColor Yellow "      - Found: $($ct.Name) in List: $($list.Title)"
            }
        }

        $siteCTs = Get-PnPContentType

        $x = $siteCTs | Where-Object {(($_.Id).StringValue -eq ($findCT))}
        if($null -ne $x)
        {
            Write-Host "  - Found: $($x.Name) in ($site.Url)"
        }

        Disconnect-PnPOnline
    }
}​

 


I have also run code that looks for a Content Type by Name with the same result (not found).

 

So, any ideas what else I could do/try to have the CT deleted?

 

The CT Hub is in need of major improvements to better support SPO. Implementation of better logging/auditing capability (tracking down what site/list/item is restricting deletion) and better provisioning functionality are some. As of now the CT Hub is a loose canon causing lot of headaches and instead of using it I'm avoiding it.

 

/Adam

0 Replies