6

I need to activate specific feature to all site collection which is inside the particular web application using powershell script?

Ayyappan Anbalagan
  • 929
  • 4
  • 15
  • 28

4 Answers4

10

Get-SPWebApplication xxx | Get-SPSite -Limit ALL | % {Enable-SPFeature "xxx" -Url $_.Url}

Per Jakobsen
  • 32,409
  • 1
  • 33
  • 62
  • Get-SPWebApplication "Web App URL"| Get-SPSite -Limit ALL | % {Enable-SPFeature "Feature GUID" -Url $_.Url} Is my parameter correct?.I am missing anything? – Ayyappan Anbalagan Apr 24 '12 at 14:01
  • Seems right. Usually I'd use Feature foldername but Guid is OK – Per Jakobsen Apr 24 '12 at 14:29
  • 1
    small tip: use a GUID instead 'name' - it's more precise and less prone to error if there are similar feature names.. – Supriyo SB Chatterjee Apr 24 '12 at 17:59
  • Name is a lot easier to read and as it ALWAYS are something like Company.Product.Solution[.SubFeature] there will never be a collision. GUID may be a bit faster, but activating/deactivating features using PowerShell is not where you get performance problems – Per Jakobsen Apr 24 '12 at 18:41
2

Try this,

$site = Get-SPSite http://yourserver

$site | Get-SPWeb -limit all | ForEach-Object {Enable-SPFeature -Identity "FeatureName" -Url $_.Url}

$site.Dispose()

Strider
  • 1,379
  • 3
  • 16
  • 28
0

Per is spot on with the command, however I was receiving an error "The Feature is not a Farm Level Feature..."

Found the answer at http://rajeshch999.blogspot.com/2012/07/powerdhell-feature-is-not-farm-level.html. The feature name was different than the name of the wsp that I installed, looking up the name in the 14 hive made it work for me.

Also, I put it into a short script for ready access if I needed it again.

# Enable-SPFeatureOnWebApplication.ps1
# script to turn on a feature on all site collections on a web app
# look-up feature name in 14 hive if not working 

$waURL = "https://your.url"
$featureName = "your.feature.name"

Get-SPWebApplication $waURL | Get-SPSite -Limit ALL | % {Enable-SPFeature $featureName -Url $_.Url}
Derbium
  • 31
  • 1
-1

other method: http://www.stefanopaterno.com/post/2011/11/15/Pillole-di-SharePoint-Management-Shell.aspx