I recently had to produce a report that identified where enterprise features were being used in a SharePoint farm, I did a quick search on google and found a PowerShell script that almost worked.
The original script was at the following site: http://panduchunduri.com/powershell-script-to-get-a-list-of-sites-that-have-enterprise-features-enabled/
This site seems to have disappeared, it’s a good thing I found it when I did.
Here is the script that I developed based off the panduchunduri script:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue | |
$enterpriseFeatureUsageFile = "C:\Reports\EnterpriseFeatureUsage.csv" | |
$enterpriseReportFile = "C:\Reports\EnterpriseReport.csv" | |
$enterpriseFeatureUsageArray = new-object System.Collections.ArrayList($null) | |
$enterpriseReportArray = new-object System.Collections.ArrayList($null) | |
function Get-PowerPivotLibs ($ssurl) | |
{ | |
$powerPivotFeatures = @("1a33a234-b4a4-4fc6-96c2-8bdb56388bd5", "e9c4784b-d453-46f5-8559-3c891d7159dd", "f8c51e81-0b46-4535-a3d5-244f63e1cab9") | |
$web = Get-SPWeb $ssurl | |
$libs = $web | | |
Select -ExpandProperty Lists | | |
Where { $_.GetType().Name -eq "SPDocumentLibrary" -and -not $_.hidden } | |
foreach($lib in $libs) | |
{ | |
if(($powerPivotFeatures -contains $lib.TemplateFeatureId)) | |
{ | |
$entry = new-object psobject -Property @{ | |
Url = ("{0}{1}" -f $ssurl.trim('/'), $list.DefaultViewUrl) | |
Feature = "PowerPivot Library" | |
} | |
$tmp = $enterpriseFeatureUsageArray.Add($entry) | |
} | |
} | |
$web.Dispose() | |
} | |
function Get-DataConnectionLibs($ssurl) | |
{ | |
$dataConnFeatures = @("00bfea71-dbd7-4f72-b8cb-da7ac0440130") | |
$web = Get-SPWeb $ssurl | |
$libs = $web | | |
Select -ExpandProperty Lists | | |
Where { $_.GetType().Name -eq "SPDocumentLibrary" -and -not $_.hidden } | |
foreach($lib in $libs) | |
{ | |
if(($dataConnFeatures -contains $lib.TemplateFeatureId)) | |
{ | |
$entry = new-object psobject -Property @{ | |
Url = ("{0}{1}" -f $ssurl.trim('/'), $lib.DefaultViewUrl) | |
Feature = "DataConnection Library" | |
} | |
$tmp = $enterpriseFeatureUsageArray.Add($entry) | |
} | |
} | |
$web.Dispose() | |
} | |
function Get-WebPartUsage($ssurl, $webpartType, $friendlyName){ | |
$web = Get-SPWeb $ssurl | |
$lists = $web | | |
Select -ExpandProperty Lists | |
Where { -ne $_.hidden } | |
if([Microsoft.SharePoint.Publishing.PublishingWeb]::IsPublishingWeb($web)) | |
{ | |
$pWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web) | |
$pages = $pWeb.PagesList | |
foreach ($item in $pages.Items) { | |
try{ | |
if($item.Url.EndsWith(".aspx")){ | |
$manager = $item.file.GetLimitedWebPartManager([System.Web.UI.WebControls.Webparts.PersonalizationScope]::Shared); | |
$wps = $manager.webparts | |
foreach($wp in $wps) | |
{ | |
if($wp.GetType().Name -eq $webpartType){ | |
$url = $web.Url +"/"+ $item.Url | |
$entry = new-object psobject -Property @{ | |
Url = $url | |
Feature = $friendlyName | |
} | |
$tmp = $enterpriseFeatureUsageArray.Add($entry) | |
} | |
} | |
} | |
}catch{ | |
$fileUrl = $web.Url +"/"+ $item.Url | |
Write-Host ("Error in Get-WebPartUsage for PublishingWeb {0}, {1}" -f $fileUrl, $webpartType) -ForegroundColor Red | |
Write-Host $_.Exception.Message -ForegroundColor Red | |
Write-Host $_.Exception.StackTrace -ForegroundColor Red | |
} | |
} | |
} else { | |
foreach($list in $lists) | |
{ | |
if($list.BaseTemplate -eq "WebPageLibrary") | |
{ | |
foreach ($item in $list.Items) { | |
try{ | |
if($item.Url.EndsWith(".aspx")){ | |
$manager = $item.file.GetLimitedWebPartManager([System.Web.UI.WebControls.Webparts.PersonalizationScope]::Shared); | |
$wps = $manager.webparts | |
foreach($wp in $wps) | |
{ | |
if($wp.GetType().Name -eq $webpartType){ | |
$url = $web.Url +"/"+ $item.Url | |
$entry = new-object psobject -Property @{ | |
Url = $url | |
Feature = $friendlyName | |
} | |
$tmp = $enterpriseFeatureUsageArray.Add($entry) | |
} | |
} | |
} | |
}catch{ | |
$fileUrl = $web.Url +"/"+ $item.Url | |
Write-Host ("Error in Get-WebPartUsage for PublishingWeb {0}, {1}" -f $fileUrl, $webpartType) -ForegroundColor Red | |
Write-Host $_.Exception.Message -ForegroundColor Red | |
Write-Host $_.Exception.StackTrace -ForegroundColor Red | |
} | |
} | |
} | |
} | |
} | |
$web.Dispose(); | |
} | |
function Get-EnterpriseWebPartsUsage($ssurl){ | |
Get-WebPartUsage $ssurl "BusinessDataActionsWebPart" "Business Data Actions WebPart" | |
Get-WebPartUsage $ssurl "BusinessDataFilterWebPart" "Business Data Filter WebPart" | |
Get-WebPartUsage $ssurl "BusinessDataDetailsWebPart" "Business Data Details WebPart" | |
Get-WebPartUsage $ssurl "BusinessDataItemBuilder" "Business Data Item Builder WebPart" | |
Get-WebPartUsage $ssurl "BusinessDataListWebPart" "Business Data List WebPart" | |
Get-WebPartUsage $ssurl "BusinessDataAssociationWebPart" "Business Data Association WebPart" | |
Get-WebPartUsage $ssurl "ChartWebPart" "Chart WebPart" | |
Get-WebPartUsage $ssurl "ExcelWebRenderer" "Excel Web Access WebPart" | |
Get-WebPartUsage $ssurl "IndicatorWebpart" "Indicator Details WebPart" | |
Get-WebPartUsage $ssurl "KPIListWebPart" "Status List WebPart" | |
Get-WebPartUsage $ssurl "VisioWebAccess" "Visio WebPart" | |
Get-WebPartUsage $ssurl "WhatsPopularWebPart" "Web Analytics Web Part" | |
Get-WebPartUsage $ssurl "ApplyFiltersWebPart" "Apply Filters Button Web Part" | |
Get-WebPartUsage $ssurl "SPSlicerChoicesWebPart" "Choice Filter Web Part" | |
Get-WebPartUsage $ssurl "UserContextFilterWebPart" "Current User Filter Web Part" | |
Get-WebPartUsage $ssurl "DateFilterWebPart" "Date Filter Web Part" | |
Get-WebPartUsage $ssurl "PageContextFilterWebPart" "Page Field Filter Web Part" | |
Get-WebPartUsage $ssurl "QueryStringFilterWebPart" "Query String (URL) Filter Web Part" | |
Get-WebPartUsage $ssurl "SpListFilterWebPart" "SharePoint List Filter Web Part" | |
Get-WebPartUsage $ssurl "ScorecardFilterWebPart" "SQL Server Analysis Services Filter Web Part" | |
Get-WebPartUsage $ssurl "SPSlicerTextWebPart" "Text Filter Web Part" | |
Get-WebPartUsage $ssurl "OWACalendarPart" "My Calendar Web Part" | |
Get-WebPartUsage $ssurl "OWAContactsPart" "My Contacts Web Part" | |
Get-WebPartUsage $ssurl "OWAInboxPart" "My Inbox Web Part" | |
Get-WebPartUsage $ssurl "OWAPart" "My Mail Folder Web Part" | |
Get-WebPartUsage $ssurl "OWATasksPart" "My Mail Folder Web Part" | |
Get-WebPartUsage $ssurl "ReportViewerWebPart" "SQL Server Reporting Services Report Viewer Web Part" | |
Get-WebPartUsage $ssurl "BrowserFormWebPart" "InfoPath Form Web Part" | |
} | |
function Get-ContentOrganizerRules($ssurl) | |
{ | |
$web = Get-SPWeb $ssurl | |
$lists = $web | | |
Select -ExpandProperty Lists | | |
Where { $_.GetType().Name -eq "SPList" -and $_.hidden } | |
foreach($list in $lists) | |
{ | |
foreach($contenType in $list.ContentTypes){ | |
if($null -ne $contenType){ | |
if($contenType.Id.ToString() -eq "0x0100DC2417D125A4489CA59DCC70E3F152B2000C65439F6CABB14AB9C55083A32BCE9C" -and $contenType.Name -eq "Rule") | |
{ | |
$entry = new-object psobject -Property @{ | |
Url = ("{0}{1}" -f $ssurl.trim('/'), $list.DefaultViewUrl) | |
Feature = "ContentOrganizerRules" | |
} | |
$tmp = $enterpriseFeatureUsageArray.Add($entry) | |
} | |
} | |
} | |
} | |
$web.Dispose() | |
} | |
function Get-InfoPathLists($ssurl) | |
{ | |
$web = Get-SPWeb $ssurl | |
$listsAndLibs = $web | | |
Select -ExpandProperty Lists | | |
Where { ($_.GetType().Name -eq "SPList" -or $_.GetType().Name -eq "SPDocumentLibrary") -and -not $_.hidden } | |
foreach($list in $listsAndLibs) | |
{ | |
switch($list.BaseType) | |
{ | |
"DocumentLibrary"{ | |
if( $list.BaseTemplate -eq "XMLForm" ) | |
{ | |
$entry = new-object psobject -Property @{ | |
Url = ("{0}{1}" -f $ssurl.trim('/'), $list.DefaultViewUrl) | |
Feature = "InfoPath Library" | |
} | |
$tmp = $enterpriseFeatureUsageArray.Add($entry) | |
} | |
} | |
{"GenericList" -or "Survey"} | |
{ | |
if($null -ne $list.Forms){ | |
foreach($form in $list.Forms){ | |
if($form.Url.EndsWith("ifs.aspx")) | |
{ | |
$entry = new-object psobject -Property @{ | |
Url = ("{0}{1}" -f $ssurl.trim('/'), $list.DefaultViewUrl) | |
Feature = "InfoPath Library" | |
} | |
$tmp = $enterpriseFeatureUsageArray.Add($entry) | |
break; | |
} | |
} | |
} | |
} | |
default { | |
} | |
} | |
} | |
$web.Dispose() | |
} | |
Function Evaluate-Site ($site) | |
{ | |
$premiumfeature = $null | |
$EnterpriseSiteCollection = "no" | |
if($site.ReadLocked -eq $false) | |
{ | |
$premiumfeature = Get-SPFeature "PremiumSite" -Site $site.Url -ErrorAction SilentlyContinue | |
if ($null -ne $premiumfeature) | |
{ | |
$EnterpriseSiteCollection = "yes" | |
} | |
$EnterpriseWeb = "no" | |
foreach ($web in $site.AllWebs) | |
{ | |
$premiumfeature = $null | |
$premiumfeature = Get-SPFeature "PremiumWeb" -Web $web.Url -ErrorAction SilentlyContinue | |
if ($null -ne $premiumfeature) | |
{ | |
$EnterpriseWeb = "yes" | |
} | |
$entry = new-object psobject -Property @{ | |
SiteUrl = $site.Url | |
SiteCollection = $EnterpriseSiteCollection | |
WebUrl = $web.Url | |
EnterpriseWeb = $EnterpriseWeb | |
} | |
$tmp = $enterpriseReportArray.Add($entry) | |
Get-InfopathLists($web.URL); | |
Get-ContentOrganizerRules($web.URL); | |
Get-DataConnectionLibs($web.URL); | |
Get-PowerPivotLibs($web.URL); | |
Get-EnterpriseWebPartsUsage($web.URL); | |
} | |
$web.Dispose(); | |
} | |
} | |
function Get-EnterpriseReport($webApp) | |
{ | |
$sites = Get-SpSite -Limit All -WebApplication $webApp | |
[int]$i = 0 | |
[int]$c = $sites.Count | |
foreach ($spsite in $sites) | |
{ | |
$i++ | |
[int]$p = 100 | |
if($c -gt 0){ | |
$p = ($i/$c)*100 | |
} | |
Write-Progress -Activity "Current SiteCollection" -CurrentOperation $spsite.Url -PercentComplete $p -Status "$i of $c" | |
Evaluate-Site ($spsite) | |
} | |
$enterpriseFeatureUsageArray | Export-Csv $enterpriseFeatureUsageFile -NoTypeInformation -Force | |
$enterpriseReportArray | Export-Csv $enterpriseReportFile -NoTypeInformation -Force | |
} | |
Get-SPWebApplication | select Url | Get-EnterpriseReport |