Delete the list content type for the specified SharePoint 2010 list using web service in powershell

Steps Involved:

  1. Open SharePoint 2010 Management Shell by going to Start | All Programs | SharePoint | Microsoft SharePoint 2010 Products | SharePoint 2010 Management Shell (Run as Administrator).
  2. Run the following script.

Powershell Script:

 
## Input Parameters required for deleting a particular list content type for the specified SharePoint 2010 list
$uri="http://serverName:10736/sites/ECT/_vti_bin/Lists.asmx?wsdl"
[
string] $contentTypeId="0x0100C158362BA107F2438E2C851F2EBD77CA"
[
string] $listName="List"

Write-Host -ForegroundColor Magenta "Deleting the content type......."
$listWebServiceReference = New-WebServiceProxy -Uri $uri -UseDefaultCredential
[
System.Xml.XmlNode]$xmlNode=$listWebServiceReference.DeleteContentType($listName,$contentTypeId)
Write-Host -ForegroundColor Green "Content type deleted successfully from the list: " $listName



Output:


Untitled.jpg


Note:

You cannot delete a list content type if that content type is currently assigned to items in the list.
When you try to run the script to delete the list content type, you will be getting the following error

a.jpg


For more information on New-WebServiceProxy please refer http://technet.microsoft.com/en-us/library/dd315258.aspx.