0

I am trying to activate Sharepoint Server publishing feature in a sharepoint online Subsite but getting error :

Feature 94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb is Web-scoped, and cannot be added to the Site.

I tried :

$site =$context.Site
$site.Features.Add($feature,$isActivate,[Microsoft.SharePoint.Client.FeatureDefinitionScope]::None)

What property I should use instead of $site ?

1
  • 1
    replace $site.Features.Add with $context.Web.Features.Add and check Commented Aug 14, 2018 at 6:01

1 Answer 1

3

$context.Site gives you the site collection context.

Feature with GUID 94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb is SharePoint Server publishing feature which as your error mentions is a web-scoped feature and not site collection scoped feature. So, you need to activate it in the SP Web context and not SP Site context.

So, modify it as in below snippet to activate it in your subsite:

$context.Web.Features.Add($feature,$isActivate,
[Microsoft.SharePoint.Client.FeatureDefinitionScope]::None)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.