This purpose of this document is to get custom feature status (Activated/Deactivated) from selected sets of site collection configured in XML file using PowerShell script. The reusable script for this job has also attached with this document. This script offers,
- To read a set of site collections, from which you want to get the feature status.
- Generate a report in excel format which will provide all the site details and feature status info.
| S. No. | Business Case |
| 1 | For several reasons we SharePoint Developer/administrators want to check if the features are activated for site collections or not. Consider a case where after the deployment administrator want to check if this feature is been activated on site collection (say 10 site collection), manually going to every managefeatures.aspx page for site and web level is not feasible. Doing like this one by one is a painful job for administrator/developer. This script will allow administrator/developers to do the job just by configuring the XML file. |
Targeted Audience
- SharePoint Application Developers
- SharePoint Administrator
- SharePoint Architect
Offerings
- One reusable PowerShell script is provided which needs to be run to get the feature status for selected set of site collections.
- Format of XML file is provided where site collection needs to be configured.
Below are the technical details for this PowerShell script,
1: Pre-requisites
- Login to server with Farm administrator account and copy the folder and paste the same to the location where you want to keep it.
- Open the folder and Configure XML file as per your requirement.
- <?xml version="1.0" encoding="utf-8" ?>
- <Configuration Environment="DEV" Version="1.0.0.0">
- <GlobalWebApplications>
- <GlobalWebApplication url="http://mywebapplicationURL">
- <CustomFeatures>
- <SiteScoped>
- <Feature id="xxxxx-xxx-xxxx-xxxx-xxxxxxxxxxx">
- <Name>XYZ Site Columns Feature</Name>
- </Feature>
- <Feature id="xxxxx-xxx-xxxx-xxxx-xxxxxxxxxxx">
- <Name>XYZ Content Types Feature</Name>
- </Feature>
- <Feature id="xxxxx-xxx-xxxx-xxxx-xxxxxxxxxxx">
- <Name>XYZ Feature</Name>
- </Feature>
- </SiteScoped>
- <WebScoped>
- <Feature id="xxxxx-xxx-xxxx-xxxx-xxxxxxxxxxx">
- <Name>XYZ Site Lists Feature</Name>
- </Feature>
- <Feature id="xxxxx-xxx-xxxx-xxxx-xxxxxxxxxxx">
- <Name>XYZ Event Receivers Feature</Name>
- </Feature>
- </WebScoped>
- </CustomFeatures>
- </GlobalWebApplication>
- </GlobalWebApplications>
- </Configuration>
Note: Name the file as Configuration.xml only.
2: Execution
Prerequisite:
Login to SharePoint Server as Farm Administrator and copy the required files (PowerShell script and configuration XML).Configure the XML file as per your requirement.
Run:
- Run the PowerShell Script as “Run as Administrator“.
- Browse the folder path where you have kept this PowerShell script file and execute a command as shown in below image.
Note:
- As shown in above image; Script will ask you for a path where you want to keep these backup file.
- In case you have typed site collection URL wrongly this script will show you an error in red color asking you to check if you have typed the URL correctly.

3: Output Folder
- Please find below folder location which we have configured in our script to maintain a site collection backup output location.
- Output will be csv file with name as GetFeatureStatusResults, will contain information like,
a. Site Template
b. Site URL
c. Site Creation Date
d. Site collection level Feature status
e. Web Level Feature status
- #check to see if the PowerShell Snapin is added
- if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) {
- Add-PSSnapin Microsoft.SharePoint.PowerShell;
- }
- ## SharePoint DLL
- [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
- $global:currentPhysicalPath = Split-Path ((Get-Variable MyInvocation -Scope 0).Value).MyCommand.Path
- [xml]$xmlinput = (Get-Content "$global:currentPhysicalPath\Configuration.xml")
- Function Get-SPWebApplication()
- {
- Param( [Parameter(Mandatory=$true)] [string]$WebAppURL )
- return [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup($WebAppURL)
- }
- #EndRegion
- #Region Check Site Level Custom Features Status
- # ===================================================================================
- # Func: Check Site Level Custom Features status
- # Desc: Check custom features status across multiple site collections
- # ===================================================================================
- function Global_CheckSiteLevelFeatureStatus([System.Xml.XmlElement]$feature, [String]$url)
- {
- $identity = $feature.id
- $featureName = $feature.Name
- $featureObject = Get-SPFeature -Site $url | Where-Object { $_.id -eq $identity }
- if ($featureObject -eq $null)
- {
- return $url
- }
- }
- #Region Check Web Level Custom Features Status
- # ===================================================================================
- # Func: Check Web Level Custom Features status
- # Desc: Check custom features status across multiple site collections
- # ===================================================================================
- function Global_CheckWebLevelFeatureStatus([System.Xml.XmlElement]$feature, [String]$url)
- {
- $identity = $feature.id
- $featureName = $feature.Name
- $featureObject = Get-SPFeature -Web $url | Where-Object {$_.id -eq $identity}
- if ($featureObject -eq $null)
- {
- return $url
- }
- }
- #EndRegion
- #Region Check Custom Features Status
- # ===================================================================================
- # Func: Global_GetSiteCollectionFeatureStatus
- # Desc: Check custom features status across multiple site collections
- # ===================================================================================
- function Global_GetSiteCollectionFeatureStatus([xml]$xmlinput)
- {
- foreach($configWebApp in $xmlinput.Configuration.GlobalWebApplications.GlobalWebApplication)
- {
- $webApp = Get-SPWebApplication($configWebApp.url)
- if($webApp -eq $null)
- {
- Write-host Web Application at url : $configWebApp.url does not Exists.. -foregroundcolor Red
- }
- else
- {
- Write-host Web Application at url : $configWebApp.url Exists.... -foregroundcolor Green
- $results = @()
- foreach($siteCollection in $webApp.Sites)
- {
- if($siteCollection -ne $null)
- {
- #Create an object to hold storage data
- $resultsData = New-Object PSObject
- $resultsData | Add-Member -type NoteProperty -name "Site URL" -value $siteCollection.Url -Force
- $resultsData | Add-Member -type NoteProperty -name "Site Template" -value $siteCollection.rootweb.WebTemplate -Force
- $resultsData | Add-Member -type NoteProperty -name "Site Created Date" -value $siteCollection.rootweb.Created.ToShortDateString() -Force
- ForEach($feature in $xmlinput.Configuration.GlobalWebApplications.GlobalWebApplication.CustomFeatures.SiteScoped.Feature)
- {
- $siteFeatureObject = Get-SPFeature -Site $siteCollection.Url | Where-Object { $_.id -eq $feature.id }
- if ($siteFeatureObject -eq $null)
- {
- $resultsData | Add-Member -type NoteProperty -name $feature.Name -value "NO" -Force
- }
- else
- {
- $resultsData | Add-Member -type NoteProperty -name $feature.Name -value "YES" -Force
- }
- }
- if($siteCollection.AllWebs.Count -gt 0)
- {
- ForEach($web in $siteCollection.AllWebs)
- {
- $resultsData | Add-Member -type NoteProperty -name "Site URL" -value $web.Url -Force
- ForEach($feature in $xmlinput.Configuration.GlobalWebApplications.GlobalWebApplication.CustomFeatures.WebScoped.Feature)
- {
- $webFeatureObject = Get-SPFeature -Web $web.Url | Where-Object {$_.id -eq $feature.id}
- if($webFeatureObject -eq $null)
- {
- $resultsData | Add-Member -type NoteProperty -name $feature.Name -value "NO" -Force
- }
- else
- {
- $resultsData | Add-Member -type NoteProperty -name $feature.Name -value "YES" -Force
- }
- }
- }
- $web.Dispose()
- }
- $results += $resultsData
- }
- else
- {
- Write-host -ForeGroundColor Red "Site Collection with this name does not exist. Please check if you have typed the URL correctly."
- }
- $siteCollection.Dispose()
- }
- $results | export-csv -Path $currentPhysicalPath/GetFeatureStatusResults.csv -notypeinformation -Force
- write-host "Report Exported successfully."
- }
- }
- }
- #EndRegion
- #Region function call
- Global_GetSiteCollectionFeatureStatus $xmlinput
- #EndRegion
Read more articles on PowerShell:


Ketak BhalsingPosted May 2, 2016, 4:14 AM EDT
Thanks Sonu
Sonu ChaudharyPosted May 2, 2016, 2:03 AM EDT
Thanks for sharing
Ketak BhalsingPosted May 1, 2016, 9:55 PM EDT
Thanks Nagaraj
Kuppurasu NagarajTOP 100Posted Apr 30, 2016, 10:21 AM EDT
Nice Sharing..
Ketak BhalsingPosted Apr 29, 2016, 10:38 PM EDT
Thanks Mohammad
Ketak BhalsingPosted Apr 29, 2016, 10:38 PM EDT
Thanka Debasis
Ketak BhalsingPosted Apr 29, 2016, 10:38 PM EDT
Thanks Vignesh
Ketak BhalsingPosted Apr 29, 2016, 10:38 PM EDT
Thanks Rahul
Rahul Kumar SaxenaTOP 100Posted Apr 29, 2016, 9:40 PM EDT
Good Work
Mohammed IbrahimPosted Apr 29, 2016, 8:44 AM EDT
nice
Debasis SahaTOP 100Posted Apr 29, 2016, 5:04 AM EDT
Good One..
Vignesh ManiTOP 100Posted Apr 29, 2016, 4:39 AM EDT
nice