Ensure_ContentType_Column_DisplayName

Language:
PowerShell
Keywords:
SharePoint
Code Snippet

Function Ensure_ContentType_Column_DisplayName( [Microsoft.SharePoint.SPContentType]$tContentType
                                              , [System.String]$tFieldName
                                              , [System.String]$tDisplayName
                                              ) {
    if ($tContentType.FieldLinks[$tFieldName] -ne $null) {
        $tFieldLink = $tContentType.FieldLinks[$tFieldName]
        if ($tFieldLink.DisplayName -ne $tDisplayName) {
            $tFieldLink.DisplayName = $tDisplayName
            Write-Output([System.String]::Format("Content Type [{0}] : Column [{1}] : Updating Display Name [{2}]", $tContentType.Name, $tFieldName, $tDisplayName))
            $tContentType.Update()
       } # change only if necessary
    } # validate that the field exists
} # Function Ensure_ContentType_Column_DisplayName(...)


Created 2011-10-13
comments powered by Disqus
Login