Category: Compliance

  • Lock Documents Labelled with Retention Labels Marked as Records in SharePoint Online

    PnP PowerShell Script to set Record Status to Locked We needed a PnP PowerShell script to iterate over documents in a library to automatically re-label documents with our new Retention Labels. The method SetComplianceTagWithMetaInfo is used to replace the Retention Label preserving the labelled date. We needed the method with metadata as the Retention Labels…

  • Set Retention Label with Metadata PowerShell

    ListItem.SetComplianceTagWithMeta Using PowerShell PnP to set Retention Label with labelled date. Not for use in Production but handy for testing. https://learn.microsoft.com/en-us/dotnet/api/microsoft.sharepoint.client.listitem.setcompliancetagwithmetainfo?view=sharepoint-csom connect-pnponline -url <url> -UseWebLogin $context = Get-PnPContext $files = get-pnplistitem -List <ListName> $file = $files[<id>] $complianceTagWrittenDate = (Get-Date -Month 1 -Day 1 -Year 2000) $file.SetComplianceTagWithMetaInfo($labelName, $isPolicyHold, $isPolicyRecord, $complianceTagWrittenDate, $userEmailAddress, $false) $context.ExecuteQuery()