I would like a script that could activate multiple features (list of features) at once in a single site collection. I was wondering if anyone out there has done this already. Any help would be appreciated.
Are you refering to a PS script that you run or do you want multiple features to be activated upon the activation of a single feature?
Logic + some code. Â Synthax may be wrong :).
$global:path = $MyInvocation.MyCommand.Path
$folderpath = split-path $global:path
$toread = Get-Content “$folderpath\input.txt”
$sc = get-spsite http://url
foreach ($line in $toread)
{
$feature = get-spfeature | where {$_.id -eq “$line} Â
if ($feature)
{
Already enabled
}
else
{
Enable-SPFeature –identity $line -URL http://somesite
}
}
Explanation.
First your notepad file will only be a bunch of feature ID’s, one per line. Â We will read every feature ID and get-spfeature. Â The get-spfeature will only return Enabled features. Â If you get an error on it , the variable will be null = the feature is not activated. Â Then we activate it!
Sources:
http://technet.microsoft.com/en-us/library/ff607945(v=office.14).aspx
http://technet.microsoft.com/en-us/library/ff607803(v=office.14).aspx