kwizcom banner advertisement

SharePoint Online: Get All Feature using PowerShell

Requirement: SharePoint Online PowerShell to List Features

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
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:
#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:
SharePoint Online: Get All Feature using PowerShell SharePoint Online: Get All Feature using PowerShell Reviewed by Salaudeen Rajack on March 22, 2018 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.