1

Need a powershell script to list all activated features, for all site collections/webs and to output to a csv, per Site Collection and to work on both 2010/2013.

Have seen things like this for a single SC but need it to re-iterate through ALL SCs in a Web App:

#------ Include the SharePoint cmdlets
Add-PsSnapin Microsoft.SharePoint.PowerShell
    $SP_SiteCollection = "https://SPWebApp"

Get-SPSite $SP_SiteCollection | % {

$results = @()

Get-SPFeature -Site $_ -Limit All | % {

$feature = $_; 
    $featuresDefn = (Get-SPFarm).FeatureDefinitions[$_.ID]; 
    $cc = [System.Globalization.CultureInfo]::CurrentCulture;

    $obj = New-Object PSObject;
    $obj | Add-Member NoteProperty  Title  $($featuresDefn.GetTitle($cc));
    $obj | Add-Member NoteProperty  Hidden $($feature.Hidden);

    $results += $obj;
}
$results | FT -auto;
}

Any suggestions?

1 Answer 1

1

Here you go, mister:

Add-PsSnapin Microsoft.SharePoint.PowerShell
    $webapp = "http://webapplication"

$results = @()

$webapp | Get-SPSite -Limit All | % {
    $siteCol = $_.RootWeb.Url
    Get-SPFeature -Site $_ | % {
        $feature = $_; 
        $obj = New-Object PSObject;
        $obj | Add-Member NoteProperty Title $($feature.DisplayName);
        $obj | Add-Member NoteProperty Hidden $($feature.Hidden);
        $obj | Add-Member NoteProperty Url $($siteCol);
        $obj | Add-Member NoteProperty Type "Site Feature";

        $results += $obj;
    }

    $_.AllWebs | % {
         $web = $_.Url
         Get-SPFeature -Web  $_ -Limit All | % {
            $feature = $_; 
            $obj = New-Object PSObject;
            $obj | Add-Member NoteProperty Title $($feature.DisplayName);
            $obj | Add-Member NoteProperty Hidden $($feature.Hidden);
            $obj | Add-Member NoteProperty Url $($web);
            $obj | Add-Member NoteProperty Type "Web Feature";

            $results += $obj;
        }
    }
}

$results | export-csv -path E:\Powershell\features.csv -NoTypeInformation

Refactor as appropriate :)

Edit: Updated the script to include Site/Web Url with every feature.

8
  • Nice, thanks, BUT just gives me a big list of activated Features.....need it listed per SC so can look at individual SCs and see what features are there SC by SC
    – Dongers
    Commented Oct 5, 2016 at 15:00
  • Well, should have added that in the question then :) Add a variable after $webapp | Get-SPSite -Limit All | % { which would get the site url ($siteurl = $_.RootWeb.Url), then add it to the $obj the same way as Title, Hidden, and Type. Do the same with the web in the second loop. Commented Oct 5, 2016 at 15:25
  • Sorry Paul, not sure what you mean...My PS is VERY basic.....I run commandletes with a few switches, not script with them! Need to be spoonfed here :) Appreciating the assistance here tho!
    – Dongers
    Commented Oct 6, 2016 at 10:46
  • Updated the answer. Now it adds a URL with every feature. You will be able to filter what you want with Excel. Commented Oct 6, 2016 at 11:25
  • Awesome Paul! Get what you did there now, thanks! Also added this: $obj | Add-Member NoteProperty ID $($feature.ID); so I could get the feature ID, which works, but then tried to add this: $obj | Add-Member NoteProperty Site ID $($siteCol.ID); to get the Site ID, which failed. Is there a way that I can query the available (site?) objects so I can get the correct format to extract the Site ID?
    – Dongers
    Commented Oct 6, 2016 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.