Activate a SharePoint Feature on All Site Collections using PowerShell

Ever wanted to enable a feature on all site collections in a SharePoint environment? Well, To activate a site collection feature in SharePoint, navigate to Site settings >> Site Collection Features >> Click on “Activate” next to the relevant feature.

How to activate a feature in SharePoint using PowerShell

How to Activate a Feature using PowerShell?
To activate a SharePoint feature on a particular site, we use Enable-SPFeature cmdlet.

Enable-SPFeature -Identity "FeatureName" -url https://SharePoint-site-URL  

Recently I had to enable a Branding feature on all sites to apply new corporate branding with the following one liner: PowerShell script.

#activate feature on all sites in all web applications in the farm
Get-SPWebApplication | Get-SPSite -Limit ALL | ForEach-Object{ Enable-SPFeature -URL $_.url -Identity (Feature Name or URL) -Confirm:$FALSE } 

Here is the E.g. for above script:

Get-SPWebApplication "" | Get-SPSite -Limit All | Get-SPWeb -Limit ALL | ForEach-Object { Enable-SPFeature "fead7313-ae6d-45dd-8260-13b563cb4c71" -Url $_.Url }

Here the PowerShell script gets all sites under the web application and activates the feature. To get the Feature GUID you can use:

Get-SPFeature | Where {$_.DisplayName -eq "FeatureName"} | Select ID

In total, The below script iterates through all web applications, site collections, checks whether the feature is already activated. If not, enables the feature on all sites.

SharePoint PowerShell to activate feature on all site collections

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Get all Site collections
$SiteColl = Get-SPWebApplication "" | Get-SPSite -Limit All 
#Target Feature to Activate
$FeatureToActivate = Get-SPFeature | Where {$_.DisplayName -eq "FeatureName"} 

#Iterate through each site collection
ForEach($Site in $SiteColl)
   #Check if Feature is already activated
   $FeatureActivated = Get-SPFeature -site $site | Where {$_.displayname -eq $FeatureToActivate.DisplayName}
   if($FeatureActivated -ne $null)
      Write-Host "Feature already activated at: "$site.Url
      #Activate the feature
      Enable-SPFeature -Identity $FeatureToActivate -URL $Site.URL -Confirm:$False
      Write-Host "Activated Feature on "$site.Url

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

5 thoughts on “Activate a SharePoint Feature on All Site Collections using PowerShell

  • Launch the SharePoint Online Management Shell as an Administrator

    2. Do Connect-PnPOnline –Url -SPOManagementShell

    3. Do Enable-PnPFeature –Identity “915c240e-a6cc-49b8-8b2c-0bff8b553ed3” -Scope Site –Force

    Note: If Enable-PnPFeature is missing in PowerShell, do: Install-Module SharePointPnPPowerShellOnline

    Please refer here :

  • Connect-PnPOnline –Url “https://yoursite” -SPOManagementShell
    Enable-PnPFeature –Identity “915c240e-a6cc-49b8-8b2c-0bff8b553ed3” -Scope Site –Force

  • How would you do this for SharePoint Online?

  • We have a feature that is installed on three web applications on a single SharePoint farm however we can have only one of the 3 activated at any time and we need to periodically change which is active for testing purposes. Because this happens randomly and potentially more than once a day we don’t want to have to keep pestering our SP admin so we would like to script the changes and set it up so others can run the script. As a result I was thinking we could set up a windows scheduler task/s which run/s a PowerShell script and then we enable PSRemote and potentially run the task from multiple places using PowerShell as well. If you could confirm this is doable and if possible an initial go at the server side feature activation/deactivation script it would be appreciated. I was thinking the script would initially deactivate them all and confirm this and then activate the selected one by some sort of parameter that is passed in ie. the web application path etc. Thank you in advance for your help. Mat


Leave a Reply

Your email address will not be published. Required fields are marked *