Ensure_List_ContentType_Enabled

Language:
PowerShell
Keywords:
SharePoint
Code Snippet

## Ensures that an SPList exists.. if it does, do nothing; if it does not, create it based on parameters
Function Ensure_List_ContentType_Enabled( [Microsoft.SharePoint.SPList]$tList
                                        , $tAllowContentTypes
                                        ) {
    if ($tList.ContentTypesEnabled -ne $tAllowContentTypes) {
        $tList.ContentTypesEnabled = $tAllowContentTypes
        
        Write-Output([System.String]::Format("List [{0}] : Setting ContentTypesEnabled [{1}]", $tList.Title, $tAllowContentTypes))
        $tList.Update()
    }
} # Function Ensure_List_ContentType_Enabled(...)


Created 2011-10-13
comments powered by Disqus
Login