SharePoint Online: Get All Feature using PowerShell

Requirement: SharePoint Online PowerShell to List Features.

How to Get Site features in SharePoint Online?

Microsoft SharePoint Online is a great platform that provides many features and functionality. There may be instances where you need to see a list of all the available features on your sites. In this blog post, I will show you how to use PowerShell to get all of the features available in SharePoint Online.

To get features in SharePoint Online, Go to Site Settings >> Click on “Site Features” to get web-scoped features. Similarly, You can click on “Site Collection Features” to get a list of site collection features.

sharepoint online site collection features powershell

SharePoint Online: Get Site Collection Features PowerShell

Let’s List SharePoint Online site features using PowerShell. This PowerShell script gets all features present in a given URL’s site and web scopes.

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

#Variables
$SiteURL="https://Crescent.sharepoint.com"

#Setup Credentials to connect
$Cred= Get-Credential
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)

#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = $Credentials

#Get Site Collection Features
$SiteCollFeatures = $Ctx.Site.Features
$Ctx.Load($SiteCollFeatures)
$Ctx.ExecuteQuery()            

#Loop through each feature and get feature data
Write-host "Site Collection Features:"
ForEach($Feature in $SiteCollFeatures)
{
    $Feature.Retrieve("DisplayName")
    $Ctx.Load($Feature)
    $Ctx.ExecuteQuery()
    $Feature | Select DisplayName, DefinitionId
}

SharePoint Online: PowerShell to Get Features

Here is the PowerShell to get SharePoint Online features at web scope.

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

#Variables
$SiteURL="https://Crescent.sharepoint.com"

#Setup Credentials to connect
$Cred= Get-Credential
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)

#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = $Credentials

#Get Web Level Features
Write-host "`nWeb Scoped Features:"
#Get web Features
$WebFeatures = $Ctx.Web.Features
$Ctx.Load($WebFeatures)
$Ctx.ExecuteQuery()

#Loop through each feature and get feature data
ForEach($Feature in $WebFeatures)
{
    $Feature.Retrieve("DisplayName")
    $Ctx.Load($Feature)
    $Ctx.ExecuteQuery()
    $Feature | Select DisplayName, DefinitionId
}

PnP PowerShell to Get Site Collection Features in SharePoint Online:

To get features from the SharePoint Online site, use the Get-PnPFeature cmdlet. If you want to filter the list of features by a specific scope, you can use the “Scope” parameter. For example, to get a list of all features that are site-scoped, run the following script:

#Config Variable
$SiteURL = "https://Crescent.sharepoint.com/Sites/Marketing"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive

#Get Site Collection Features
Get-PnPFeature -Scope Site | Select DisplayName, DefinitionID

Similarly, you can retrieve web-scoped features as:

#Config Variable
$SiteURL = "https://Crescent.sharepoint.com/Sites/Marketing"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)

#Get Web Features
Get-PnPFeature -Scope Web | Select DisplayName, DefinitionID

Related Articles:

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

Leave a Reply

Your email address will not be published. Required fields are marked *