Skip to content

spo file retentionlabel ensure

Apply a retention label to a file

Usage

m365 spo file retentionlabel ensure [options]

Options

-u, --webUrl <webUrl>
URL of the site where the retentionlabel from a file to apply is located
--fileUrl [fileUrl]
The site- or server relative URL of the file that should be labelled. Specify either fileUrl or fileId but not both.
i, --fileId [fileId]
The UniqueId (GUID) of the file that should be labelled. Specify either fileUrl or fileId but not both.
--name <name>
Name of the retention label to apply to the file.
-h, --help [help]
Output usage information. Optionally, specify which section of command's help you want to see. Allowed values are options, examples, remarks, response, full. Default is full.
--query [query]
JMESPath query string. See http://jmespath.org/ for more information and examples
-o, --output [output]
Output type. json,text,csv,md. Default json
--verbose
Runs command with verbose logging
--debug
Runs command with debug logging

Remarks

You can also use spo listitem retentionlabel remove for removing the retentionlabel from a listitem.

Examples

Applies a retention label to a file based on the label name and the fileUrl

m365 spo file retentionlabel ensure --webUrl https://contoso.sharepoint.com/sites/project-x --fileUrl '/Shared Documents/Document.docx' --name 'Some label'

Applies a retention label to a file based on the label name and the fileId

m365 spo file retentionlabel ensure --webUrl https://contoso.sharepoint.com/sites/project-x --fileId '26541f96-017c-4189-a604-599e083533b8'  --name 'Some label'

Response

The command won't return a response on success.