SharePoint Online: Delete a Content Type using PowerShell

Requirement: Delete a Content Type from the SharePoint Online site.

How to delete a content type in SharePoint Online?

Have you ever created a SharePoint Online content type and decided that you no longer want it? Or want to permanently get rid of a particular content type as you are experiencing issues and need to delete and recreate it? In this article, we will walk you through the steps to delete a content type in SharePoint Online. We’ll also share the PowerShell to delete a content type in SharePoint Online.

Content types that are not used by lists or libraries can be deleted. To delete a content type in SharePoint Online, follow these steps:

  1. Login to your SharePoint Online site >> Click on Site settings gear >> Site Settings.
  2. In the Site settings page, click on “Site Content Types”. 
  3. Under the Site Content Types page, click on the name of the content type you wish to delete. 
  4. Click on the “Delete this site content type” link and confirm the prompt once.
    sharepoint online delete content type using powershell

Delete Content Type using PowerShell in SharePoint Online:

Keep in mind that deleting a content type is a permanent action (can’t be undone!) – be sure that you really don’t need it before proceeding! Here is the PowerShell to delete content type in SharePoint Online.

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

Function Delete-ContentType()
        [Parameter(Mandatory=$true)] [string] $SiteURL,
        [Parameter(Mandatory=$true)] [string] $ContentTypeName

    Try {
        $Cred= Get-Credential
        $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)

        #Setup the context
        $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
        $Ctx.Credentials = $Credentials
        #Get the content type from web
        $ContentTypeColl = $Ctx.Web.ContentTypes
        #Check if the content type exists in the site        
        $ContentType = $ContentTypeColl | Where {$_.Name -eq $ContentTypeName}
        If($ContentType -eq $Null)
            Write-host "Content Type '$ContentTypeName' doesn't exists in '$SiteURL'" -f Yellow
            #delete the content type

            Write-host "Content Type '$ContentTypeName' deleted successfully!" -ForegroundColor Green
    Catch {
        write-host -f Red "Error Deleting Content Type!" $_.Exception.Message

#Set parameter values

#Call the function
Delete-ContentType -SiteURL $SiteURL -ContentTypeName $ContentTypeName

PnP PowerShell to Delete Content Type in SharePoint Online

Let’s see how to use the PnP PowerShell cmdlet Remove-PnPContentType to delete a content type in SharePoint Online:

#Config Variables
$SiteURL = ""
$ContentTypeName ="Project Proposal V1"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)

#Get the content type
$ContentType = Get-PnPContentType -Identity $ContentTypeName

    Remove-PnPContentType -Identity $ContentTypeName -Force 

Cannot Delete Content Type in SharePoint Online? 
Can’t delete the content type? Getting “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.” Error? Well, This could be because you may have lists or libraries associated with the content type you are trying to delete. Here is the solution: SharePoint Online cannot delete content type

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

Leave a Reply

Your email address will not be published. Required fields are marked *