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: 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:
- To activate a SharePoint Online feature using PowerShell: SharePoint Online Activate Publishing Feature using PowerShell
- To deactivate SharePoint Online feature PowerShell: SharePoint Online PowerShell to Disable Feature