PowerShell to check which SharePoint sites have a specific Feature enabled

Hey Guys,

The other day our Records Management team was adamant in determining who in the company is utilizing SharePoint’s Records Management feature.

With over 350 site collections it would be a real pain to go to each site and check if its enabled. Luckily PowerShell offers a nice easy way of checking this. Here is a really simple PowerShell function that checks which sites accross a specified web application has a specific feature enabled.

#add sharepoint cmdlets
if ((Get-PSSnapin -Name Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue) -eq $null )
Add-PsSnapin Microsoft.SharePoint.PowerShell
function Feature-Exists
Get-SPSite -WebApplication $webApp | Select-Object Url, @{
    Label="Exists"; Expression=
Get-SPFeature -Site $_.Url | ForEach-Object{
if($_.displayName -eq $featureName){

We can run the function to just get a quick listing or pipe it out to a csv file by doing:

Feature-Exists -webApp "http://site" -featureName "InPlaceRecords" | Export-Csv -NoTypeInformation -Path "D:\report.csv" 

The catch is you do need to know the exact display name of the feature before using the function. The best way of doing this is to use the command Get-SPFeature -site “http://yourSite” and find the display name of the feature in question. You could also modify the function to use the feature’s GUID instead.


PowerShell to list size of content databases in SharePoint Web Application

Hey Guys,

Here’s another quick little PowerShell command for listing all content DBs and their respective sizes. It is quite handy for doing some auditing and determining if you are performing best practices.

PS C:\> $DBs = Get-SPContentDatabase -WebApplication "http://WebAppUrl" 
PS C:\> $DBs | Format-Table Name, @{Label="Size"; Expression={$_.DiskSizeRequired / 1073741824}}
Name                                                                    Size
----                                                                    ----
ContentDB1                                                     183.9931640625
ContentDB2                                                           58.03125