I want a PowerShell script to find where Features are activated in a site collection and its sites/subsites
Like for example feature "Enterprise feature"
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityThis might also help someone:
Get-SPSite -Limit All| Where-Object {(Get-SPFeature "PublishingSite" -ErrorAction SilentlyContinue -Site $_.Url) -ne $null } | Select Url
Taken from this blog post. See full reference: https://technet.microsoft.com/en-us/library/ff607945.aspx
You have to iterate through all sites/webs for specific web application and call this snippet:
$o.Features | ? { $_.DefinitionId -eq 'featureId' } | % { $_.Parent }
Where $o can be SPWebApplication, SPSite or SPWeb object
EDIT: fullscript
$url = "http://localhost"
$featureId = "00bfea71-a83e-497e-9ba0-7a5c597d0107"
$s = Get-SPSite $url
Function FindFeature($obj, $fId)
{
$obj.Features | ? { $_.DefinitionId -eq $fId } | % { $_.Parent.Url }
$obj.AllWebs | % {
$_.Features | ? { $_.DefinitionId -eq $featureId } | % { $_.Parent.Url }
if ($_.AllWebs.Count -gt 0) {
FindFeature($_, $fId);
}
}
}
FindFeature $s $featureId