Please check the below 'PnP.Powershell' sample script with necessary modules/dlls and query to set the value.
[CmdletBinding(DefaultParameterSetName="UseCustomTermSet")]
Param
(
[Parameter(Mandatory=$true)]
$url
)
$module = Get-Module PnP.Powershell
if(!$module)
{
Import-Module PnP.Powershell
$module = Get-Module PnP.Powershell
}
$base = $module.ModuleBase
$clientDll = [System.Reflection.Assembly]::LoadFile("$base\Core\Microsoft.SharePoint.Client.dll")
$runtimeDll = [System.Reflection.Assembly]::LoadFile("$base\Core\Microsoft.SharePoint.Client.Runtime.dll")
$policydll = [System.Reflection.Assembly]::LoadFile("$base\Core\Microsoft.Office.Client.Policy.dll")
$cred = Get-Credential
Context
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($url)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($cred.UserName, $cred.Password)
[Microsoft.SharePoint.Client.CompliancePolicy.SPPolicyStoreProxy]::SetAllowFilesWithKeepLabelToBeDeletedODB($ctx, $true)
[Microsoft.SharePoint.Client.CompliancePolicy.SPPolicyStoreProxy]::SetAllowFilesWithKeepLabelToBeDeletedSPO($ctx, $true)
$ctx.ExecuteQuery()