Table of Contents

Add-PnPFileSensitivityLabel

SYNOPSIS

Required Permissions

  • Microsoft Graph API : One of Files.ReadWrite.All, Sites.ReadWrite.All

Required Billing

  • Microsoft Graph API: The assignSensitivityLabel API used by this cmdlet will not function without billing setup. Consult the RELATED LINKS section.

Add the sensitivity label information for a file in SharePoint.

SYNTAX

Add-PnPFileSensitivityLabel -Identity <String> -SensitivityLabelId <Guid> [-AssignmentMethod <Enum>] [-JustificationText <string>] [-Batch <PnPBatch>]

DESCRIPTION

The Add-PnPFileSensitivityLabel cmdlet adds the sensitivity label information for a file in SharePoint using Microsoft Graph. It takes a URL as input, decodes it, and specifically encodes the '+' character if it is part of the filename. It also takes the sensitivity label Id , assignment method and justification text values as input. You can optionally provide a PnP batch so the label assignment is queued and executed together with other batched Graph calls.

EXAMPLES

Example 1

This example adds the sensitivity label information for the file at the specified URL.

Add-PnPFileSensitivityLabel -Identity "/sites/Marketing/Shared Documents/Report.pptx" -SensitivityLabelId "b5b11b04-05b3-4fe4-baa9-b7f5f65b8b64" -JustificationText "Previous label no longer applies" -AssignmentMethod Privileged

Example 2

This example removes the sensitivity label information for the file at the specified URL.

Add-PnPFileSensitivityLabel -Identity "/sites/Marketing/Shared Documents/Report.pptx" -SensitivityLabelId "" -JustificationText "Previous label no longer applies" -AssignmentMethod Privileged

Example 3

This example queues two label assignments in a single Microsoft Graph batch for improved throughput.

$batch = New-PnPBatch

Get-PnPFile -Folder "/sites/Marketing/Shared Documents" -Recursive -Filter "*.pptx" | ForEach-Object {
  Add-PnPFileSensitivityLabel -Identity $_ -SensitivityLabelId "b5b11b04-05b3-4fe4-baa9-b7f5f65b8b64" -AssignmentMethod Privileged -Batch $batch
}

Invoke-PnPBatch -Batch $batch

PARAMETERS

-Identity

The server relative path to the file, the unique identifier of the file, the listitem representing the file, or the file object itself on which we are adding the sensitivity label.

Type: FilePipeBind
Parameter Sets: (All)

Required: True
Position: 0
Default value: None
Accept pipeline input: True
Accept wildcard characters: False

-SensitivityLabelId

ID of the sensitivity label to be assigned, or empty string to remove the sensitivity label.

Type: string
Parameter Sets: (All)

Required: True
Position: Named
Default value: None
Accept pipeline input: True
Accept wildcard characters: False

-AssignmentMethod

The assignment method of the label on the document. Indicates whether the assignment of the label was done automatically, standard, or as a privileged operation (the equivalent of an administrator operation).

Type: Guid
Parameter Sets: (All)
Accepted values: Standard, Privileged, Auto
Required: False
Position: Named
Default value: None
Accept pipeline input: True
Accept wildcard characters: False

-JustificationText

Justification text for audit purposes, and is required when downgrading/removing a label.

Type: Guid
Parameter Sets: (All)

Required: False
Position: Named
Default value: None
Accept pipeline input: True
Accept wildcard characters: False

-Batch

Allows queueing the label assignment in an existing PnP batch. Use Invoke-PnPBatch to execute all queued operations.

Type: PnPBatch
Parameter Sets: Batch

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False