SharePoint Online SPOMod: Remove-SPOContentType
This article describes a function of a custom SharePoint Online module available for download and installation on GitHub where it welcomes all your suggestions and contributions.
Remove-SPOContentType
Removes content type.
Parameters
ContentTypeID | Mandatory | String. The ID of the content type to be removed. |
ListTitle | Optional | String. The title of the list where the content type is located. Use only if you want to remove a list content type, and not site content type. |
Examples
----- EXAMPLE 1 ------
Remove a content type from a list.
Remove-SPOContentType -ContentTypeID "0x0100E6BD49EA28F1AE4BA49AA555FB4B179A" -ListTitle MyList6
----- EXAMPLE 2 ------
Remove a content type from the site.
Remove-SPOContentType -ContentTypeID "0x010058453F904AB1EB468BA00E0D81952A5B"
Watch out For...
Exception calling "ExecuteQuery" with "0" argument(s): "Cannot invoke method or retrieve property from null object. Object returned by the following call stack is null." GetById/ ContentTypes/ Web/ Microsoft.SharePoint.SPContext.Current
The Content Type you are looking for is not in that list or site. If you were using -List parameter, try targeting a site content type. If you were trying to remove a content type from site, check if it is not added to the list directly.
See Also
SPOMod Cmdlets and Resources
Connect-SPOCSOM
Get-SPOList
New-SPOSiteContentType
New-SPOListContentType
New-SPOSiteContentTypeColumn
Get-SPOContentType
Wiki: SharePoint Online content types in Powershell: Add
Wiki: SharePoint Online content types in Powershell: Get
Wiki: SharePoint Online content types in Powershell: Edit