sharepoint online – Delete Unique Permission for item level

SharePoint Online: Delete Unique Permissions from a List/Library using PnP PowerShell

#Set Variables
$SiteURL = ""
$ListName = "Documents"
#Connect to PNP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)
#Get all list items in batches
$ListItems = Get-PnPListItem -List $ListName -PageSize 5000
#Iterate through each list item
ForEach($ListItem in $ListItems)
    #Check if the Item has unique permissions
    $HasUniquePermissions = Get-PnPProperty -ClientObject $ListItem -Property "HasUniqueRoleAssignments"
        $Msg = "Deleting Unique Permissions on {0} '{1}' at {2} " -f $ListItem.FileSystemObjectType,$ListItem.FieldValues("FileLeafRef"),$ListItem.FieldValues("FileRef")
        Write-host $Msg
        #Delete unique permissions on the list item
        Set-PnPListItemPermission -List $ListName -Identity $ListItem.ID -InheritPermissions

SharePoint Server: Remove unique permissions on List Items

Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
#Variables for Web URL, List Name
$WebURL ="http://spserver/sites/sitename"
$ListName ="Documents"
#Get the list items with Unique permissions
$ListItems = (Get-SPweb $WebURL).lists.TryGetList($ListName).Items | Where {$_.HasUniqueRoleAssignments}
# If List Exists with Unique permission
Foreach($ListItem in $ListItems)
      #Reset broken list item inheritance
      Write-host "Broken Inheritance Reset on List Item:" $ListItem.URL