Ensure_SiteColumn_OfType_Lookup

Creating lookup columns require additional data
Language:
PowerShell
Keywords:
SharePoint
Code Snippet

Function Ensure_SiteColumn_OfType_Lookup( [Microsoft.SharePoint.SPWeb]$tWeb
                                        , $tFieldName
                                        , [Microsoft.SharePoint.SPList]$tLookupList
                                        , [System.Boolean]$isRequired = $false
                                        ) {

    if (!$tWeb.Fields[$tFieldName]) {
        $tWeb.Fields.AddLookup($tFieldName, $tLookupList.ID, $isRequired) | Out-Null

        Write-Output([System.String]::Format("Column [{1}] : Adding to Web [{0}]", $tWeb.Url, $tFieldName))
    }
} # Function Ensure_SiteColumn(...)


Created 2011-10-13
comments powered by Disqus
Login