cancel
Showing results for 
Search instead for 
Did you mean: 

How to locate Site Collections using a feature via PowerShell

aaron_labiosa
Nintex Newbie
10 0 1,883

Products: SharePoint 2010/2013

Recently a case came in where the company needed to locate where a feature had been activated within a specific Web Application as it was causing troubles with a Web.Config file.

We were able to use this script to locate the sites with the features enabled.

Run the below (attached as well as a *.txt file for your convenience) PowerShell script (PowerShell ISE works well) from a SharePoint Server:

PowerShell Script
  1. foreach ($site in $(Get-SPWebApplication http://yourUrl).Sites)
  2. {
  3.         foreach ($feature in $site.Features)
  4.         {
  5.                 if ($feature.DefinitionId -match [Guid]'00000000-0000-0000-0000-000000000000')
  6.                 {
  7.                         $site
  8.                 }
  9.         }
  10. }

Usage:

  • Replace http://yourUrl with the URL of your Web Application.
  • Replace 00000000-0000-0000-0000-000000000000 guid with the Guid of the FeatureDefinitionId to be located.

To obtain the FeatureDefinitionId's of all features in the SharePoint farm you can run this Cmdlet: Get-SPFeature