Share via


Remove-FileLabel

Removes the sensitivity label for a file or removes the protection according to the label configuration or custom permissions.

Syntax

RemoveLabel

Remove-FileLabel
    [-Path] <String[]>
    [-JustificationMessage <String>]
    [-RemoveLabel]
    [-PreserveFileDetails]

RemoveLabelProtection

Remove-FileLabel
    [-Path] <String[]>
    [-JustificationMessage <String>]
    [-RemoveLabel]
    [-RemoveProtection]
    [-PreserveFileDetails]

RemoveProtection

Remove-FileLabel
    [-Path] <String[]>
    [-JustificationMessage <String>]
    [-RemoveProtection]
    [-PreserveFileDetails]

Description

For the Microsoft Purview Information Protection client, the Remove-FileLabel cmdlet removes a sensitivity label for one or more files.

Examples

Example 1: Remove a label from a file

PS C:\> Remove-FileLabel C:\Projects\Analysis.docx -RemoveLabel -JustificationMessage 'The previous label no longer applies'

FileName                   Status Comment
--------                   ------ ------------
C:\Projects\Analysis.docx  Success

This command removes the existing label from the file named C:\Projects\Analysis.docx, and specifies a mandatory justification message.

This justification method is required because the relevant sensitivity label policy setting is enabled to require justification for removing a label.

Note

If the label you're removing was protecting your file using a template, this command removes both the label and the protection.

If the label you're removing was protecting your file using custom permissions, this command removes only the label.

Example 8: Remove protection from a file

PS C:\> Remove-FileLabel C:\Projects\Analysis.docx -RemoveProtection

FileName                   Status Comment
--------                   ------ ------------
C:\Projects\Analysis.docx  Success

This command removes protection from a single file named Analysis.docx.

Example 9: Remove protection and a label from a file

PS C:\> Remove-FileLabel C:\Projects\Analysis.docx -RemoveProtection -RemoveLabel -JustificationMessage 'The previous label no longer applies'

FileName                   Status Comment
--------                   ------ ------------
C:\Projects\Analysis.docx  Success

This command removes the label and custom protection from a single file named Analysis.docx. Because the policy is configured to require justification to remove a label, the justification reason is also supplied so that the command can complete without prompting the user for the reason.

Parameters

-JustificationMessage

The justification reason for removing a label or removing protection if the sensitivity labeling policy requires users to supply this information. If removing a label triggers the justification and this reason is not supplied, the label is not removed. In this case, the status returned is "Skipped" with the comment "Justification required".

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Path

Specifies a local path, network path, or SharePoint Server URL to the files for which you want to remove the label and protection information.

Wildcards are not supported and WebDav locations are not supported.

For SharePoint paths, the following are supported:

  • SharePoint Server 2022
  • SharePoint Server 2019
  • SharePoint Server 2016
  • SharePoint Server 2013

For example:

  • C:\Folder\
  • C:\Folder\Filename
  • \\Server\Folder
  • http://sharepoint.contoso.com/Shared%20Documents/Folder

Paths can include spaces when you enclose the path value with quotes.

Parameter properties

Type:

String[]

Default value:None
Supports wildcards:False
DontShow:False
Aliases:FullName, FileName

Parameter sets

(All)
Position:0
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:True
Value from remaining arguments:False

-PreserveFileDetails

Specify this parameter to leave the modified date (Windows and SharePoint) and modified by (SharePoint) values unchanged for documents that you label:

  • For local or network files, the Date modified value remains unchanged.

  • For SharePoint files, the Modified date and Modified by values remain unchanged.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-RemoveLabel

Removes any label that has been applied to a file.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

RemoveLabel
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
RemoveLabelProtection
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-RemoveProtection

Removes protection from a file. If the file is labeled, the label is not removed.

You must have sufficient usage rights or be a super user for your organization to remove protection from files. For more information, see Configuring super users for Azure Rights Management and discovery services or data recovery.

Use the Remove-FileLabel PowerShell cmdlet to enable removal of protection from container files (zip, .rar, .7z, and .pst).

Note

  • This remove protection capability is disabled by default and must first be enabled using the Set-LabelPolicy cmdlet.

  • For .pst files, 5 GB is the maximum file size supported with this cmdlet.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

RemoveLabelProtection
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False
RemoveProtection
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

Inputs

System.String

Outputs

Microsoft.InformationProtection.Powershell.AIP.Results.SetAIPFileResult