top of page

Set-SPListContentTypes PowerShell Cmdlet

1.0 Description:

A custom Powershell cmdlet to add, remove and change the order of the content types in SharePoint 2010 list

2.0 Set-SPListContentTypes

NAME

Set-SPListContentTypes


SYNTAX

Set-SPListContentTypes [-url] <String> [-ListName] <String> [[-ContentTypeToAdd] <List`1>] [[-ContentTypeToRemove] <List`1>]   [[-ContentTypeOrder] <List`1>]   


Parameters

Parameter Required Type Description

Url Required System.String Specifies the URL of the site collection.


ListName Required System.String Specifies the list name.


ContentTypeToAdd Optional System.Collections. Add list of content types to the . Generic.List<T> SharePoint list.


ContentTypeToRemove Optional System.Collections. Remove list of content types Generic.List<T> from the SharePoint list.


ContentTypeOrder Optional System.Collections. Change the order of the Generic.List<T> . content types in the list.


Detailed Description EXAMPLE 1

Set-SPListContentTypes http://sitename/sites/test -ListName "tl"

–ContentTypeToAdd @("ct1","ct2") – ContentTypeToRemove

@("Content1","Content2") – ContentTypeOrder @("ct2","ct1")


The above cmdlet will

  • Add the content type's ct1 & ct2 to the list "tl".

  • Remove the content types Content1 & Content2 from the list "tl".

  • Content types Order will be ct2, ct1.

  • Default content type will be first one ct2.


3.0 Register the cmdlet:

  • Unzip the source code.

  • Go to the installer folder.

  • Run Install.bat.anavijai.SP2010.PowerShell.dll will be installed in the gac.

  • Go to 14\CONFIG\POWERSHELL\Registration and check whether anavijaiSP2010Cmdlet.xml is available.

  • Run "SharePoint 2010 Management Shell" as administrator.

  • Check whether the cmdlet is registered by executing the following commands. - Get-Command Set-SPListContentTypes - Help SPListContentTypes

erver'>

0 comments
bottom of page