Here we have 2 PowerShell scripts to Enable-Disable a feature using CSOM

Enable Feature

  • User: user in the Office 365 tenant
  • Password: user password
  • Url: Full URL to the site or web
  • Scope: Site / Web. Scope of the feature that we want to activate.
  • Feature: Feature Id.
  • Force: Re-enable feature if is already activated
  • Sandbox: true/false. Basically this param indicates if the solution where the feature lives, is a Farm solution, or a Sandbox solution.

About the Sandbox param. This is a little confuse if we take a look to the MSDN documentation

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.featurecollection.add.aspx

If we look at the FeatureDefinitionScope enum, we have:


However, the documentation in the Add method says that you can only use 2 values: Farm and Site. This param can make you be wrong, because you can think that is the Scope of the feature, so, if you want to activate a Web scope feature, you’d try with the Web value in the enum type. However, this param indicates the scope of the Solution that contains the feature: Farm or Sandbox solution, so, the possible values are only Farm and Site.

Microsoft, Why are you using an Enum with 4 values in a function that only accept 2 possible values from the Enum ??? OK… that’s another question…

Let’s see now how we can use the same approach to Disable a Feature.

Disable Feature

That’s all, hope it helps!!

Luis Manez

@luismanez