SharePoint Online: Get All Feature using PowerShell

Requirement: SharePoint Online PowerShell to List Features

How to Get Site features in SharePoint Online?

To get features in SharePoint Online, Go to Site Settings >> Click on “Site Features” to get web scoped features. 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://crescenttech.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://crescenttech.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:

We can get all site collection scoped features from a site with:

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

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

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

Similarly, you can retrieve web scoped features as:

#Config Variable
$SiteURL = "https://crescenttech.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 is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

Leave a Reply