Delete content type from SharePoint list using PowerShell

This PowerShell SharePoint tutorial explains, how to delete the content type from SharePoint list using Powershell in SharePoint 2013/2016/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 a different types of solution to fix this issue. 1st we need to remove all content type which is associated from 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 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.”

You may like following SharePoint content type tutorials:

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

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

Rajkiran Swain

Rajkiran is currently working as a SharePoint Consultant in QATAR . Rajkiran having 7+ years of experience in Microsoft Technologies such as SharePoint 2019/2016/2013/2010, MOSS 2007,WSS 3.0, Migration, Asp.Net, C#.Net, Sql Server, Ajax, jQuery etc.He is C#Corner MVP (2 Times).

  • […] Delete content type from SharePoint list using PowerShell […]

  • […] Delete content type from SharePoint list using PowerShell […]

  • […] Delete content type from SharePoint list using PowerShell […]

  • >