SharePoint Online: Deactivate Feature using PowerShell
Requirement: Deactivate a feature in SharePoint online using PowerShell.
How to Deactivate a Feature in SharePoint Online?
Follow these steps to deactivate a SharePoint Online feature:
SharePoint Online PowerShell to Disable Feature:
Here is how to disable a SharePoint Online feature using the Client Side Object Model and PowerShell.
SharePoint Online: Deactivate a Feature using PnP PowerShell
Let's disable publishing feature at site level using PnP PowerShell Disable-PnPFeature cmdlet:
Similarly, to disable a feature in SharePoint Online at web level using PnP PowerShell, use:
How to Deactivate a Feature in SharePoint Online?
Follow these steps to deactivate a SharePoint Online feature:
- Navigate to the site where the feature needs to be deactivated.
- On the site's home page, click the Settings gear icon and then Site Settings option from the Settings menu.
- On the Site Settings page, Click the "Manage Site Features" link under Site Actions section.
- On the Site Features page, click the "Deactivate" button next to the site feature you desire to deactivate.
- The feature status is changed to and the associated feature capabilities are disabled in the site.
SharePoint Online PowerShell to Disable Feature:
Here is how to disable a SharePoint Online feature using the Client Side Object Model and PowerShell.
#Load SharePoint Online CSOM Assemblies Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" #Function to Disable Feature in SharePoint Online Function Disable-SPOFeature { param ($SiteCollURL,$UserName,$Password,$FeatureGuid) Try { #Setup the context $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteCollURL) $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $Password) $Ctx.Credentials = $Credentials $Site=$Ctx.Site #Check the Feature Status $FeatureStatus = $Site.Features.GetById($FeatureGuid) $FeatureStatus.Retrieve("DefinitionId") $Ctx.Load($FeatureStatus) $Ctx.ExecuteQuery() #Deactivate the feature if its enabled if($FeatureStatus.DefinitionId -ne $null) { Write-Host "Disabling Feature $FeatureGuid..." -ForegroundColor Yellow $Site.Features.Remove($FeatureGuid, $true) | Out-Null $Ctx.ExecuteQuery() Write-Host "Feature has been disabled on site $SiteCollURL!" -ForegroundColor Green } else { Write-host "Feature is Not Active on the Site collection!" -ForegroundColor Red } } Catch { write-host "Error: $($_.Exception.Message)" -foregroundcolor Red } } #Parameters to Activate Feature $SiteCollURL = "https://Crescent.sharepoint.com/sites/Demo" $UserName = "[email protected]" $Password = "Password goes here" $FeatureGuid= [System.Guid] ("f6924d36-2fa8-4f0b-b16d-06b7250180fa") #Publishing Feature $SecurePassword= ConvertTo-SecureString $Password –asplaintext –force #Disable Feature Disable-SPOFeature -SiteCollURL $SiteCollURL -UserName $UserName -Password $SecurePassword -FeatureGuid $FeatureGuidThis deactivates publishing feature using PowerShell in SharePoint Online.
SharePoint Online: Deactivate a Feature using PnP PowerShell
Let's disable publishing feature at site level using PnP PowerShell Disable-PnPFeature cmdlet:
#Config Variable $SiteURL = "https://crescenttech.sharepoint.com/Sites/Procurement" $FeatureId = "f6924d36-2fa8-4f0b-b16d-06b7250180fa" #Site Scoped Publishing Feature #Connect to PNP Online Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential) #get the Feature $Feature = Get-PnPFeature -Scope Site -Identity $FeatureId #Get the Feature status If($Feature.DefinitionId -ne $null) { #Deactivate the Feature Write-host -f Yellow "Deactivating Feature..." Disable-PnPFeature -Scope Site -Identity $FeatureId -Force Write-host -f Green "Feature Deactivated Successfully!" } Else { Write-host -f Yellow "Feature is Not active!" }
Similarly, to disable a feature in SharePoint Online at web level using PnP PowerShell, use:
#Config Variable $SiteURL = "https://crescenttech.sharepoint.com/Sites/Procurement" $FeatureId = "94c94ca6-b32f-4da9-a9e3-1f3d343d7ecb" #Web Scoped Publishing Feature #Connect to PnP Online Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential) #get the Feature $Feature = Get-PnPFeature -Scope Web -Identity $FeatureId #Get the Feature status If($Feature.DefinitionId -ne $null) { #Activate the Feature Write-host -f Yellow "Deactivating Feature..." Disable-PnPFeature -Scope Web -Identity $FeatureId -Force Write-host -f Green "Feature Deactivated Successfully!" } Else { Write-host -f Yellow "Feature is Not active!" }To activate a feature in SharePoint Online using PowerShell, refer: SharePoint Online: Activate Feature using PowerShell
I want to disable Site notebook feature all subsites, How to do that?
ReplyDeleteUse this PowerShell to deactivate a feature on all sites: SharePoint Online: Disable a Feature for All Sites using PowerShell
Delete