Ensure_ContentType_Name

This just sets the name of the content type.

NOTES:

Exception setting "Name": "The content type name 'abc : 1' cannot contain: \  / : * ? " # % < > { } | ~ & , two consecutive periods (..), or special characters such as a tab."

Language:
PowerShell
Keywords:
SharePoint
Code Snippet

## Ensures that a Content Type's name is $Name

Function Ensure_ContentType_Name( [Microsoft.SharePoint.SPContentType]$tContentType

                                , [System.String]$Name

                                ) {

    if ($tContentType.Name -ne $Name) {

        $tContentType.Name = $Name

 

        Write-Output([System.String]::Format("Content Type [{0}] : Changing Name to [{1}]", $tContentType.Name, $Name))

        $tContentType.Update()

    }   

} # Function Ensure_ContentType_Name(...)


Created 2012-10-03
comments powered by Disqus
Login