Get and set Microsoft sensitivity labels.
$ ./labels get .
LabelInfo FilePath NumLabels Labels
true ./123.xlsx 1 [3de9faa6-9fe1-49b3-9a08-227a296b54a6 f49dfc2f-b2b1-4605-accd-09d3ac0089a8]
true ./ABC.xlsx 1 [3de9faa6-9fe1-49b3-9a08-227a296b54a6 f49dfc2f-b2b1-4605-accd-09d3ac0089a8]
true ./Test.xlsx 1 [3de9faa6-9fe1-49b3-9a08-227a296b54a6 f49dfc2f-b2b1-4605-accd-09d3ac0089a8]
false ./dd.xlsx 0 []
false ./file_example.xlsx 0 []
labels.exe [--flags] get [path]
labels.exe [--flags] set [path] [labelId] [tenantId]
commands
get: list sensitivity labels for the provided file or directory
set: apply the provided sensitivity label ID to the provided file or directory
arguments
path: path to the file or directory
labelId: sensitivity label ID to apply
tenantId: microsoft tenant ID to apply
flags
--labeled: only show files with labels
--summary: show summary of results
--recurse: recurse through subdirectory files
--dry-run: show results of set command without applying
--tmp-dir: temporary directory for file extraction
--verbose: show diagnostic output
examples
labels.exe get .
labels.exe get "path\to\dir" --labeled --recursive --json
labels.exe set "path\to\file.xlsx" "1234-label-id-1234" "4321-tenant-id-4321"
- Find supported file archives (xlsx, docx, pptx)
- Extract each archive to a temporary directory
- Read labels from tmpDir/docMetadata/LabelInfo.xml
- (optional) Modify
id
(labelId) andsiteId
(tenantId) - Display results
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<clbl:labelList xmlns:clbl="http://schemas.microsoft.com/office/2020/mipLabelMetadata">
<clbl:label id="{c55117b6-35e7-4866-8da0-8aeab17385d2}" enabled="1" method="Privileged" siteId="{37b1cb57-8023-4b88-bae9-2b532b0b70a6}" contentBits="0" removed="0" />
</clbl:labelList>