This article describes a function of a custom SharePoint Online module available for download and installation here.
Click delete this content type and receive the following error message:
Most likely one of the items is still the content type. The following cmdlets will show how to find and remove such items.
2. Download SPOMod available here.
3. Open SPOMod current file (in ISE or NotePad) and scroll down to the following lines:
# Paths to SDK. Please verify location on your computer.
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"
4. Make sure that the paths correspond to the locations of SDK on your machine. Most often you need to change 16 into 15.
5. Save the file.
6. Open Powershell as an Administrator.
7. Run Import-Module PathToTheSPOModFile
8. Connect-SPOCSOM
9. Ready to go :)
Enter the following cmdlet. It will remove all items matching specific ContentTypeID:
foreach($item
in(Get-SPOListItems -ListTitle YOURLISTTITLE -IncludeAllProperties $true
| where {$_.ContentTypeId -match "0x0111002440A334027B18479FB4EDAFF1F149FF00AC40BD13F3F10A46A50C44E1F6D19EF0"})) { Remove-SPOListItem -ListTitle YOURLISTTITLE -ItemID $item.ID}
How to find content type ID in SharePoint Online?
The items will be removed from the Recycle Bin as well! There is no way to retrieve them.
Step 1. Navigate to the list. Open the ribbon and click Modify view:
Step 2.Content type"
Step 3. Save the view.
Step 4. In the list click on the content type column and select the content type you are about to delete.
Step 5. You will see the applied filter.
Step 6. Mark all the items (they all should be showing the content type you want to delete).
Step 7. Delete the items.
Other articles on content types and Powershell:
Scripts on content types available from Technet Gallery:
Get all properties of all content types in a SharePoint site Get All Properties of All Content Types (Detailed) Get All Properties of All Content Types in All Lists (Detailed) across one site
Get properties of a single content type by its ID Get content types belonging to a group Get All Hidden Content Types added to the site Get Single Content Type - Array Method Get Names of all content types added to your SPO lists Get Names of All Content Types Get Names of all Available Content Types Get Content Types Derived From One Parent Get content types which cannot be modified Get Content Types with a particular column Find Custom Display Forms Deployed on your lists using Powershell Verify the content types used in your lists against the default ones Retrieve all Content Types from a Content Type Hub and their DisplayFormTemplate