Consider a scenario where you have a list of SharePoint Feature and you want to activate the same in number of site collection consider 200 site collections. What you will do ? Surely we won’t be doing it manually; we will be automating the process. PowerShell script is the answer for the same. In this article I will be showing you how to activate a list of features on number of site collection.
Here I have created an XML configuration file; where we are defining the list of features and list of Site collection and web applications we are targeting for this activity. Please find below is the structure of the XML file.
- <?xml version="1.0" encoding="utf-8" ?>
- <Configuration Environment="DEV" Version="1.0.0.0">
- <GlobalWebApplications>
- <GlobalWebApplication url="http://mydev.sharepoint.com/">
- <SiteCollections>
- <SiteCollection relativeURL="sites/TestSite1 " />
- <SiteCollection relativeURL="sites/TestSite2" />
- </SiteCollections>
- <CustomFeaturesToActivate>
- <Feature id="b176b379-ea64-4a10-b48f-dedfb6bddf81">
- <Name>Global.SharePoint.Infrastructure Site Columns Feature</Name>
- </Feature>
- <Feature id="f1a196ad-72bc-4950-a8f1-830155e2389f">
- <Name>Global.SharePoint.Infrastructure Content Types Feature</Name>
- </Feature>
- <Feature id="00ab0f8b-d183-4103-82af-4e331118aa31">
- <Name> Global.SharePoint.Infrastructure Site Lists</Name>
- </Feature>
- <Feature id="00a51d3d-874e-4b46-a972-b151468940c7">
- <Name> Global.SharePoint.Core Event Receivers</Name>
- </Feature>
- </CustomFeaturesToActivate>
- <CustomFeaturesToDeActivate>
- <Feature id="040a8ee5-5dcd-4a6b-a258-b010e0a975aa">
- <Name> Global.SharePoint.MyProject Site Lists</Name>
- </Feature>
- <Feature id="9a6f5d6a-d54c-4378-a195-06bcd21ed8d2">
- <Name> Global.SharePoint.MyProject Event Receivers</Name>
- </Feature>
- </CustomFeaturesToDeActivate>
- </GlobalWebApplication>
- </GlobalWebApplications>
- </Configuration>
As shown in file above define your
environment DEV/UAT/PROD (DEV in my case),
GlobalWebApplication URL (
http://mydev.sharepoint.com/) ,list of site collections, list of
CustomFeaturesToActivate and list of
CustomFeaturesToDeActivate with their Ids and Name to avoid confusion
.
PowerShell script is as follows.