0

How to remove list Content Type Association from Document Library.I have 14 content types in my SP 2013 portal. I want to know how to achieve this using PowerShell?

   $msite= Get-SPSite $siteurll
   $AllWebsCollection = $msite.AllWebs
   foreach($singlweb  in $AllWebsCollection)
   {
      $objWeb =  Get-SPWeb  $singlweb.Url
      foreach($singleDocLib in $DocLibss)
      {
          $ContentTypeName= "Memo"
          $singCTYpe=    $singleDocLib.ContentTypes[$ContentTypeName]
          # how to delete the list content type association ?
      }

1 Answer 1

3

Try

$singleDocLib.ContentTypes.Delete($singCType.Id)
$singleDocLib.Update()
4
  • am getting the below error: Cannot convert argument "id", with value: "", for "Delete" to type "Microsoft.SharePoint.SPContentTypeId": "Cannot convert null to type "Microsoft.SharePoint.SPContentTypeId"." At line:19 char:6 + $singleDocLibKG.ContentTypes.Delete($singCType.Id) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodException + FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument May 30, 2015 at 12:11
  • It seems $singCTYpe is null. Make sure you are getting $singCTYpe properly. May 30, 2015 at 12:18
  • Amal, my mistake. I was accessing the wrong object.Now its corrected. May 30, 2015 at 12:25
  • I added the $myct.ReadOnly=$false $myct.Update() also. then its worked May 30, 2015 at 12:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.