SharePoint Online: Delete Content Type using PowerShell

Requirement: SharePoint Online Delete Content Type from site.

How to delete a content type in SharePoint Online?

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

  • Login to your SharePoint Online site >> Click on Site settings gear >> Site Settings 
  • In the Site settings page, Click on “Site Content Types” under 
  • Under Site Content Types page, Click on the name of your content type you wish to delete. 
  • Click on “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:

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

#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 is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

Leave a Reply