Use the code listed in the embed below to add or remove a feature on a site – un-comment the relevant section to set the script to enable or disable the feature

[csharp]$username = "someone@domain.com"<br> $securePassword = Read-Host -Prompt "Please enter your password" -AsSecureString<br> $url = "https://tenant.sharepoint.com/siteURL"</p> <p>$securePassword = ConvertTo-SecureString $Password -AsPlainText -Force</p> <p>#Below lines are needed if the SharePoint powershell install is not globally defined<br> Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"<br> Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"</p> <p># connect/authenticate to SharePoint Online and get ClientContext object..<br> $clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($url)<br> $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $securePassword)<br> $clientContext.Credentials = $credentials</p> <p>if (!$clientContext.ServerObjectIsNull.Value)<br> {<br> Write-Host "Connected to SharePoint Online site: ‘$Url’" -ForegroundColor Green<br> }<br> $feature=Read-Host -Prompt "Enter the feature id, e.g. for SharePoint Server Publishing it’s 94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb"<br> $featureguid=new-object System.Guid $feature<br> $site = $clientContext.Web<br> #uncomment the line below to disable the feature<br> #$site.Features.Remove($featureguid, $true);</p> <p>#uncomment the line below to enable the feature<br> #$site.Features.Add($featureguid, $true, [Microsoft.SharePoint.Client.FeatureDefinitionScope]::Site)</p> <p>$clientContext.ExecuteQuery()<br> Write-Host "Feature added/removed for" $site.Url</p> <p>[/csharp]