Quantcast
Channel: SharePoint Diary
Viewing all articles
Browse latest Browse all 1058

Find All Inactive Features in SharePoint with PowerShell

$
0
0
What is inactive Feature in SharePoint? Well, Features which are installed but not activated anywhere!

Here is the PowerShell script to find inactive features for SharePoint:
Add-PSSnapin "Microsoft.SharePoint.Powershell" -ErrorAction SilentlyContinue

$InactiveFeatures = @()

#Get All installed features on respective scopes
$WebAppFeatures = Get-SPFeature | Where-Object {$_.Scope -eq "WebApplication" }
$siteFeatures = Get-SPFeature | Where-Object {$_.Scope -eq "Site" }
$WebFeatures = Get-SPFeature| Where-Object {$_.Scope -eq "Web" }

Write-host "Checking Web Application Scoped Features..."
foreach ($WebAppFeature in $WebAppFeatures)
{
$Flag = $False
foreach ($WebApp in Get-SPWebApplication)
{
if ((Get-SPFeature -WebApplication $WebApp.URL | Where-Object {$_.Id -eq $WebAppFeature.id}) -ne $null)
{
#We found that the Feature is active, Lets end up the loop
$Flag = $True
break
}
}
if($Flag -eq $False)
{
Write-Host "$($WebFeature.DisplayName) is not Active on any Web Application!)"
}

}

Write-Host "`nChecking Site Collection Scoped Features..."
foreach ($SiteFeature in $SiteFeatures)
{
$Flag = $False
:WebAppLoop1 foreach ($WebApp in Get-SPWebApplication)
{
foreach($site in $WebApp.Sites)
{
if ((Get-SPFeature -Site $Site.URL | Where-Object {$_.Id -eq $SiteFeature.id}) -ne $null)
{
#We found that the Feature is active, Lets end up the loop
$Flag = $True
break WebAppLoop1
}
}
}
if($Flag -eq $False)
{
Write-Host "$($SiteFeature.DisplayName) is not Active on Any Site Collection!"
}
}

Write-host "`nChecking Web Scoped Feature..."
foreach ($WebFeature in $WebFeatures)
{
$Flag = $False
#I'm limiting to a single web application, Remove ""http://sharepoint.crescent.com" to process all WebApps
:WebAppLoop2 foreach ($WebApp in Get-SPWebApplication "http://sharepoint.crescent.com")
{
foreach($Site in $WebApp.Sites)
{
foreach($Web in $Site.AllWebs)
{
if ((Get-SPFeature -Web $Web.URL | Where-Object {$_.Id -eq $WebFeature.id}) -ne $null)
{
#We found that the Feature is active, Lets end up the loop
$Flag = $True
break WebAppLoop2
}
}
}
}
if($Flag -eq $False)
{
Write-Host "$($WebFeature.DisplayName) is not Active on Any Web!"
}
}

Please note: There could be many OOTB features stay Inactive based on the site template we use. So, Use this script to get an insight of your custom features deployed to the SharePoint 2013/SharePoint 2010 environments.

To get a report on features activated on various scopes, refer:

Viewing all articles
Browse latest Browse all 1058

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>