Ensure_FeatureActivated

Language:
PowerShell
Keywords:
SharePoint
Code Snippet

Function Ensure_FeatureActivated( [Microsoft.SharePoint.SPFeatureCollection]$tFeatures
                               , [System.Guid]$tFeatureId
                               , [Microsoft.SharePoint.SPFeatureDefinitionScope]$tFeatureScope = [Microsoft.SharePoint.SPFeatureDefinitionScope]::Null
                               ) {
    if (($tFeatures | where { $_.DefinitionId -eq $tFeatureId }) -eq $null) {
        Write-Output([System.String]::Format("Enabling Feature with Id [{0}]", $tFeatureId))
        
        if ($tFeatureScope -eq [Microsoft.SharePoint.SPFeatureDefinitionScope]::None) {
            $tFeatures.Add($tFeatureId) | Out-Null
        } else {
            $tFeatures.Add($tFeature.Id, $false, $tFeatureScope) | Out-Null
        }
    }
} # Function Ensure_FeatureActivated(...)


Created 2011-10-13
comments powered by Disqus
Login