次の方法で共有


PowerShell to List Activated Features for a Site and Web

Here is a snippet of Windows PowerShell code to list all the activated Features for a site collection (SPSite):

 Get-SPSite https://sharepoint2010 | % {

    $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;
}

Here is a snippet of Windows PowerShell code to list all the activated Features for an individual web (SPWeb).

 Get-SPWeb https://sharepoint2010/subsite | % {

    $results = @()

    Get-SPFeature -Web $_ -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;
}

Please note, this formatted output will not match the output you see on the ManageFeatures.aspx page for two reasons.  First, the ManageFeatures.aspx page will show you all of the deactivated Features in the farm that could be activated for the site collection or individual web as well as all of the activated Features for the site or web.  Second, the ManageFeatures.aspx page does not display Features marked as Hidden.

The output from this PowerShell script will show you the hidden and non-hidden Features that are activated for the site or web.

Comments

  • Anonymous
    December 18, 2014
    Thank you greatly, this post helped alot. I discovered that if the site contains custom WebTemplate features ("Web Template feature of exported template"), the call to .GetTitle($cc) throws an error "You cannot call a method on a null-valued expression." because they do not exist in the (Get-SPFarm).FeatureDefinitions.  Calling $.GetTitle($cc) directly returns all the site features' titles including those for exported web templates. Get-SPSite http://sharepoint2010/subsite | % {    $results = @()    Get-SPFeature -Site $ -Limit All | % {        $cc = [System.Globalization.CultureInfo]::CurrentCulture;        $obj = New-Object PSObject;        $obj | Add-Member NoteProperty  Title  $($.GetTitle($cc));        $obj | Add-Member NoteProperty  Hidden $($.Hidden);        $results += $obj;    }    $results |FT -auto; }