Sharepoint 2010: How to remove columns from content types using powershell

By peter.stilgoe









Some columns once added to a content type dont allow you to remove them, you dont got a delete button. To delete one such column from your cotent type you can use the following Sharepoint Powershell Script:

#Attach to the web and content type
$web = Get-SPWeb http://fldev003/sites/pjstest/
$ct = $web.ContentTypes["Post"]

#Get link to the columnn from the web
$spFieldLink = New-Object Microsoft.SharePoint.SPFieldLink ($web.Fields["Page Image"])

#Remove the column from the content type and update
$ct.FieldLinks.Delete($spFieldLink.Id)
$ct.Update()

#Dispose of the web object
$web.Dispose()




Share

, , ,

About... peter.stilgoe

peter.stilgoeThis author published 497 posts in this site.
Sharepoint, InfoPath, K2, Nintex, Business Process Mapping, Business Intelligence, Automation, ECM, Document Management, Document Imaging, Internet Marketing & Online Business Consultant Email / MSN: pstilgoe@hotmail.com LinkedIn: Pete Stilgoe - Sharepoint Consultant









Share

FacebookTwitterEmailWindows LiveTechnoratiDeliciousDiggStumbleponMyspaceLikedin

2 Comments

  • [...] Answer to no. 3 from here [...]

    • At 2012.01.22 13:32, Jeanne said:

      I get an exception when I run it
      exception calling “Update” with “0″ argument “Attempted to perform an unauthorized operation.
      At line:1 char:11
      + $ct.Update <<<<
      + CategoryOnfo :Not Specificed {}, MethodInvocationException
      + FullyQualifiedErrorID: DotNetMethodException

      Any suggestions?

      [Reply]

      (Required)
      (Required, will not be published)