Posted on:
Categories: Office 365;PowerShell;SharePoint
Description:

Recently I was faced with an error message in our SharePoint online tenant when trying to activate the Community Site feature.
The error message looked like this:

Site
The Site scoped feature being activated has a dependency on hidden Site Collection scoped feature 'FeatureDefinition/15/4326e7fc-f35a-4b0f-927c-36264b0a4cf0' (ID: '4326e7fc-f35a-4b0f-927c-36264b0a4cf0'). Hidden features cannot be auto-activated across scopes. There may be one or more visible Site Collection scoped features that auto-activate the dependent hidden feature.​


Obviously, a feature was missing, but the error message did not tell what feature exactly was missing. Only the GUID of the feature was displayed.
To solve this problem, the ​SharePoint Online Management Shell can be used. If this helpful shell has not been installed, you can download the installer from this site: https://www.microsoft.com/en-ca/download/details.aspx?id=35588​
After the shell has been installed, be sure to run it as an Administrator!


To activate a feature by it's feature ID, you can use this script:

$$programFilesDirectory = [environment]::getfolderpath("programfiles")
add-type -Path $programFilesDirectory'\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll'
Write-Host 'Enter credentials and site URL'
$siteurl = Read-Host "Site Url"
$featureGUID = Read-Host "GUID of feature"
$username = Read-Host "User Name"
$password = Read-Host -AsSecureString "Password"

[Microsoft.SharePoint.Client.ClientContext]$ClientContext = New-Object Microsoft.SharePoint.Client.ClientContext($siteurl)
$ClientContext.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
$site = $ClientContext.Site;
$feature = new-object System.Guid $featureGUID
$site.Features.Add($feature, $true, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None);
$ClientContext.ExecuteQuery();
Write-Host 'Feature enabled​'


Simply copy and paste this script​ to the SharePoint Online Management Shell and run it.


Be sure to enter the the site URL, the GUID of the feature and proper credentials. Usually it will take a little time (about 10-15 seconds) for SharePoint online to activate the feature. If you do not get an error message (and see 'Feature enabled'), the feature should have been activated.

​​