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?
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