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?

1 Answer 1

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

2
  • doesn't work for me. powershell doesn't throw any error .feature doesn't activate Commented Jun 9, 2014 at 6:08
  • Do you pass in a correct URL base? Commented Jun 9, 2014 at 7:04

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.