Activating a SharePoint Feature on Multiple Sites or Site Collections using PowerShell

I need to either activate or even deactivate certain features on multiple site collections.
So the below script will allow you to do this..

First step create a text file in the below format, you only need to define the URL for each Site collection or site.

SiteURL
http://sharepointsuresh/sites/site1
http://sharepointsuresh/sites/site2
http://sharepointsuresh/sites/site3
http://sharepointsuresh/sites/site4
http://sharepointsuresh/sites/site5
http://sharepointsuresh/sites/site6

You can list all features installed on your sites by using the following PowerShell:
Get-SPFeature | Sort -Property Scope,DisplayName | FT -GroupBy Scope DisplayName,Id

Then use the below PowerShell Script:

$SiteList = Import-Csv Sites.txt
ForEach ($item in $SiteList)
{
            If ($item -ne $null)
            {
                Write-Host "Activated Branding Feature for: $($item.SiteURL)" -foregroundcolor cyan;  
                Enable-SPFeature -id "Specify GUID" -URL "$($item.SiteURL)"
                Write-Host "Activated Branding Features for: $($item.SiteURL)" -foregroundcolor green;
                Disable-SPFeature -id "Specify GUID" -URL "$($item.SiteURL)"    
                Write-Host "De-Activated Branding Features for: $($item.SiteURL)" -foregroundcolor red;
            }
}
$web.update()
$web.Dispose()

Comments

  1. Hi,

    Does this work? My doubt is where is $web declare to update and dispose

    ReplyDelete
  2. If is there,how about else statement ? does it jump to $web.update() without $web variable in the scripts?

    ReplyDelete
  3. Great script! This approach really saves a lot of manual effort when you need to activate or deactivate SharePoint features across multiple site collections.
    If you're interested in learning something fascinating besides tech, I highly recommend checking out this wonderful article about ants being the doctors of nature.
    Also, feel free to visit Daily Sabas BD for a variety of informative articles! 🌟

    ReplyDelete

Post a Comment

Popular posts from this blog

Managed Path with WildCard and Explicit Inclusion

List All SharePoint 2010 PowerShell Commands