Delete content type from SharePoint list using PowerShell (Another site or list is still using this content type)

This PowerShell SharePoint tutorial explains, how to delete the content type from SharePoint list using Powershell in SharePoint 2013/2016/2019 or SharePoint Online.

Also, we will resolve the error which comes while trying to delete the content type from the SharePoint list. The error comes as Another site or list is still using this content type. If you would still like to delete it, please remove the content type from all sites and lists and then try again.

The error will looks like below:

delete content type from list powershell sharepoint
delete content type from list powershell sharepoint

Delete or remove the content type from SharePoint list

There are different types of solutions to fix this issue. 1st we need to remove all content types which is associated with the list. We can use PowerShell, PnP PowerShell, or manually remove the content type from the SharePoint List.

Powershell command to remove the content type from List in SharePoint

Below is the PowerShell script to remove the content type from list in SharePoint. If you are new to PowerShell in SharePoint, check out the PowerShell SharePoint tutorial.

$siteURL = "The Site url"
$contentType = "Content type Name"
$web = Get-SPWeb $siteURL
$ct = $web.ContentTypes[$contentType]
if ($ct) {
$ctusage = [Microsoft.SharePoint.SPContentTypeUsage]::GetUsages($ct)
foreach ($ctuse in $ctusage) {
$list = $web.GetList($ctuse.Url)
$contentTypeCollection = $list.ContentTypes;
$contentTypeCollection.Delete($contentTypeCollection[$ContentType].Id);
Write-host "Deleted $contentType content type from $ctuse.Url"
}
$ct.Delete()
Write-host "Deleted $contentType from site."
} else { Write-host "Nothing to delete." }
$web.Dispose()

Delete content Type from list in SharePoint manually

We can also delete the content type one by one by the manual procedure from the list settings page in SharePoint. Before delete, we need to find the references in which list it exactly used then delete it one by one.

delete content type from list powershell sharepoint
delete content type from list powershell sharepoint

PNP PowerShell script to Delete Content Type in SharePoint Online

We can also use PnP PowerShell in SharePoint Online to delete content type from the SharePoint list.

#Config sitename
$SiteURL = "https://pikasha12.sharepoint.com"
$ContentTypeName ="Name of your content Type"
 
#Connect to PNP Online SharePoint
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)
 
#Get the content type
$ContentType = Get-PnPContentType -Identity $ContentTypeName
 
If($ContentType)
{ 
    Remove-PnPContentType -Identity $ContentTypeName -Force
}

Once your script will execute successfully next check your page. If still error is appear on your page then follow the points below.

  • Delete from site recycle bin.
  • Delete from Site Collection > Site Settings > Site Collection Administration > Recycle Bin.
  • Delete from End User Recycle Bin Items.
  • Delete from “Deleted From End User Recycle Bin.”

Another site or list is still using this content type

Here is another solution for, Another site or list is still using this content type. if you would still like to delete it, please remove the content type from all sites and lists and then try again.

Recently for one of our custom visual studio workflow requirements, we created few content types (inherited from Workflow Task (SharePoint 2013) content type). We have used these content types in our task list on various sites and subsites.

Now when we try to delete the content types we got the below error:

Sorry, something went wrong.

Another site or list is still using this content type. If you would still like to delete it please remove the content type from all sites and lists and then try again

SharePoint online Another site or list is still using this content type
SharePoint online Another site or list is still using this content type

Another site or list is still using this content type

We have removed the content types from the attached SharePoint list. And then we removed the items from the recycle bin too. But still, it was showing the same error.

The above exercise we have in all the lists and libraries from the sites and also from the subsites. But still, it was showing the error.

Then I noticed, we have created two items by using the content type in one of our task lists.

Another site or list is still using this content type
Another site or list is still using this content type

When we delete the above items from the list, I can able to delete the content types from the SharePoint list.

You may like following SharePoint content type tutorials:

I hope this SharePoint tutorial helps to delete the content type from SharePoint list using PowerShell or PnP PowerShell.

Also, we saw, how to fix errors, another site or list is still using this content type. if you would still like to delete it, please remove the content type from all sites and lists and then try again.

  • >