PowerShell script to list sites that have a specified feature enabled

The following PowerShell script will enumerate all sites within a Site Collection and report on where a particular feature has been enabled using the Get-SPWeb cmdlet.  In the example I am reporting on the SharePoint Server Enterprise Site Features feature and have excluded sites within the app domain.

To use the script just change the SiteCollection, DefinitionID and AppDomain variables

Add-PSSnapin "Microsoft.SharePoint.PowerShell"

$SiteCollection = "http://portal.lab.local"
$AppDomain = "*apps.lab.local*"
$DefinitionID = "0806d127-06e6-447a-980e-2e90b03101b8"

$Sites = Get-SPWeb -Site $SiteCollection -Limit All

$OutputArray = @()
$Properties = @{Site='Site'; URL='URL'; Status='Status'}
$NewObject = New-Object PSObject -Property $Properties

ForEach ($Site In $Sites | Where-Object Url -NotLike $AppDomain)
{
   If($Site.Features | Where-Object DefinitionID -Eq $DefinitionID)
   {
      $Properties = @{Site=$Site; URL=$Site.Url; Status="Enabled"}
      $NewObject = New-Object PSObject -Property $Properties
      $OutputArray += $NewObject
   }
   Else
   {
      $Properties = @{Site=$Site; URL=$Site.Url; Status="Disabled"}
      $NewObject = New-Object PSObject -Property $Properties
      $OutputArray += $NewObject
   }
}

$OutputArray | Format-Table -Property Site,Url,Status -AutoSize

The output will look something like this:

Check_Feature

Note: You can use the Get-SPFeature cmdlet to display a list of features and their ID:

Get-SPFeature | Sort DisplayName | Format-Table -Property DisplayName,ID -AutoSize

[BlogBookmark] [Blogsvine] [del.icio.us] [Digg] [Facebook] [Furl] [Google] [LinkedIn] [MySpace] [Reddit] [Slashdot] [StumbleUpon] [Twitter] [Windows Live] [Yahoo!] [Email]