Hi All,
One of our requirements is to activate the publishing feature (“SharePoint Server Publishing Infrastructure”) on our one of the SharePoint online site collection which is of type Team site.
So we have CSOM + PowerShell approach and used following CSOM code to activate the features using PowerShell script.
- #getting all site features
- $siteFeatures = $clientContext.Site.Features
- $clientContext.Load($siteFeatures)
- $clientContext.ExecuteQuery()
- #activating “SharePoint Server Publishing Infrastructure” feature
- $featureId = “f6924d36-2fa8-4f0b-b16d-06b7250180fa”
- $fId = [GUID]$featureId
- $siteFeatures.Add($fId, $true, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::Site)
- $clientContext.ExecuteQuery()
An error occurred activating Feature. Error detail: Exception calling "ExecuteQuery" with "0" argument(s): "Feature with Id 'f6924d36-2fa8-4f0b-b16d-06b7250180fa' is not installed in this farm, and cannot be added to this scope.”
After digging a lot and went through couple of blogs, noticed that, in some blogs FeatureDefinitionScope is set to None. We tried this option and it worked like charm.
So it looks like as,
- $siteFeatures.Add($fId, $true,
- [Microsoft.SharePoint.Client.FeatureDefinitionScope]::None)
- using System;
- namespace Microsoft.SharePoint.Client
- {
- public enum FeatureDefinitionScope
- {
- None,
- Farm,
- Site,
- Web
- }
- }
Summary
While activating feature using CSOM it doesn’t accept respective scope (Site or Web), we need to provide feature definition scope as None.
Thanks!

Gowtham RajamanickamPosted Mar 11, 2015, 7:06 AM
good one..