Skip to content

New command: Get a list of retention labels for a specific SharePoint site #4152

@martinlingstuyl

Description

@martinlingstuyl

Usage

m365 spo web retentionlabel list [options]

Description

Get a list of retention labels that's available on a site.

Options

Option Description
-u, --webUrl <webUrl> The url of the web to get retentionlabels for.

Examples

Get a list of retention labels for the Sales site

m365 spo web retentionlabel list --webUrl 'https://contoso.sharepoint.com/sites/sales'

Response

[
    {
      "AcceptMessagesOnlyFromSendersOrMembers": false,
      "AccessType": null,
      "AllowAccessFromUnmanagedDevice": null,
      "AutoDelete": true,
      "BlockDelete": true,
      "BlockEdit": true,
      "ComplianceFlags": 5,
      "ContainsSiteLabel": false,
      "DisplayName": "",
      "EncryptionRMSTemplateId": null,
      "HasRetentionAction": true,
      "IsEventTag": false,
      "MultiStageReviewerEmail": null,
      "NextStageComplianceTag": null,
      "Notes": null,
      "RequireSenderAuthenticationEnabled": false,
      "ReviewerEmail": null,
      "SharingCapabilities": null,
      "SuperLock": false,
      "TagDuration": 2555,
      "TagId": "80a43bcd-1024-477e-a624-3c717cb774a2",
      "TagName": "Some  label",
      "TagRetentionBasedOn": "CreationAgeInDays",
      "UnlockedAsDefault": false
    }
]

Additional Info

The following endpoint can be used:
https://contoso.sharepoint.com/sites/sales/_api/SP.CompliancePolicy.SPPolicyStoreProxy.GetAvailableTagsForSite(siteUrl=@a1)?@a1='https://contoso.sharepoint.com/sites/sales'

This endpoint is also used by SharePoint itself to retrieve the options of Dropdown boxes when applying a label to a document in SharePoint library forms:
image

More information

Why this command?

This API essentially retrieves purview retention labels, just like this related purview command. The shape of the data is different though, and you need SharePoint permissions (Sites.Read is probably enough)

It also can be used with app only permissions, while the graph command from purview currently throws an exception in app only mode.

Text output properties

Properties visible in text output mode should be: TagId, TagName

Beta notice

The endpoint that's used is in prerelease mode according to the Microsoft documentation above, so we should add a beta notice to the docs.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions