0

I need a PowerShell script for activating a specific site collection feature in every site collection of mysite if not already activated.

How can this be done?

| improve this question | | | | |
2

If the are all under a managed path you can do something like this:

$sites = Get-SPSite https://mysiteurl/* -Limit ALL
foreach($site in $sites){
    Enable-SPFeature "name or GUID here" -Url $site.Url 
    $site.Dispose()
}

This will throw errors on sites where the feature is already activated, but since it is PowerShell the execution will continue for the other sites. You could use ErrorAction SilentlyContinue on Enable-SPFeature to not get the error output

| improve this answer | | | | |
  • doesn't work for me. powershell doesn't throw any error .feature doesn't activate – SharePointMan Jun 9 '14 at 6:08
  • Do you pass in a correct URL base? – Robert Lindgren Jun 9 '14 at 7:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.