Enable Site collection feature using Powershell Script
$site = Get-SPSite http://sitecollectionurl
Enable-SPFeature -Identity “Feature GUID” -Url $site.Url
$site.Dispose()
SiteURL
http://sharepoint/sites/site1
http://sharepoint/sites/site2
http://sharepoint/sites/site3
http://sharepoint/sites/site4
Then use the below code and save it ps1 file and excute as PowerShell comand:
$site = Get-SPSite http://sitecollectionurl
Enable-SPFeature -Identity “Feature GUID” -Url $site.Url
$site.Dispose()
Enable feature on large no. of site collection, first create a text file in the below format, you only need to define the URL for each Site collection or site.
SiteURL
http://sharepoint/sites/site1
http://sharepoint/sites/site2
http://sharepoint/sites/site3
http://sharepoint/sites/site4
Then use the below code and save it ps1 file and excute as PowerShell comand:
$SiteList = Import-Csv Siteslist.txt
ForEach ($item in $SiteList)
{
If ($item -ne $null)
{
Write-Host "Activated Feature for: $($item.SiteURL)" -foregroundcolor cyan;
Enable-SPFeature -id "FeatureGUID"-URL "$($item.SiteURL)"
Disable-SPFeature -id "FeatureGUID" -URL "$($item.SiteURL)"
Write-Host "Deactivated Feature for: $($item.SiteURL)" -foregroundcolor green;
}
}
$web.update()
$web.Dispose()
Check sites to make sure features are activated properly.
No comments:
Post a Comment