SharePoint Online: Delete Permission Level using PowerShell

Requirement: SharePoint Online Remove permission level using PowerShell

Warning: Never delete any OOTB default permission levels in SharePoint!

How to Delete a Permission Level in SharePoint Online?

Deleting a permission level is a great way to clean up your permissions structure If you no longer need a custom permission level. This blog post will show you how to delete a permission level in SharePoint Online.

To delete an existing permission level in SharePoint Online, follow these steps:

  1. Navigate to the SharePoint Online Site collection where you want the permission level to be deleted. (Make sure you are on the root web!)
  2. Click on Settings gear >> Select Site Settings from the Settings menu.
  3. On the Site Settings page, click on the “Site Permissions” link under the “Users and Permissions” section.
  4. On the Permissions page, click on the “Permission Levels” button from the Permissions tab of the ribbon. 
  5. On the Permission Levels page, Tick the checkbox(es) for permission levels you want to delete, and click the “Delete Selected Permission Levels” link.
  6. Confirm the prompt with the OK button.
    sharepoint online delete permission level

This deletes the permission level in SharePoint Online!

PowerShell to Remove Permission Level in SharePoint Online:

Use this PowerShell script if you want to delete a custom permission level. Please note that deleting a permission level is easy, but it’s important to remember that this action cannot be undone!

#Load SharePoint 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"

#Parameters
$SiteURL = "https://Crescent.sharepoint.com"
$PermissionLevelName ="Contribute Without Delete"

#Get credentials to connect
$Cred = Get-Credential

Try {
    #Setup the Context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName, $Cred.Password)

    #Get the Web
    $Web = $Ctx.Web

    #Get the Permission Level and Delete
    $RoleDefinition = $Web.RoleDefinitions.GetByName($PermissionLevelName)
    $RoleDefinition.DeleteObject()
    $Ctx.ExecuteQuery()
 
    Write-Host -f Green "Permission Level Deleted Successfully!"
    }
Catch {
    write-host -f Red "Error:" $_.Exception.Message
}

SharePoint Online: PnP PowerShell to Delete Permission Level

Here is how to remove a permission level in SharePoint Online with PnP PowerShell:

#Set Variables
$SiteURL = "https://crescent.sharepoint.com/sites/Marketing"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)

#Get a Permission level
$PermissionLevel = Get-PnPRoleDefinition -Identity "Contribute Without Delete"

If($PermissionLevel -ne $Null)
{
    Remove-PnPRoleDefinition -Identity $PermissionLevel -Force
    Write-host -f Green "Permission Level Removed Successfully!"
}

If you want to create a new permission level, use: How do I create a permission level in SharePoint Online?

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

Leave a Reply

Your email address will not be published. Required fields are marked *