Re-labeling Sensitivity labels quickly through powershell

Aaron Schulte 20 Reputation points
2024-11-18T16:32:23.6633333+00:00

I need a way to use powershell to change the sensitivity label of some files that have an old label applied to them to the current label I have for all files.

Azure Policy
Azure Policy
An Azure service that is used to implement corporate governance and standards at scale for Azure resources.
926 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,634 questions
0 comments No comments
{count} votes

Accepted answer
  1. Pavan Minukuri 520 Reputation points Microsoft Vendor
    2024-11-19T16:53:17.4533333+00:00

    Hi @Aaron Schulte
    Welcome to Microsoft Q&A Forum, thanks for asking question here...1
    To change the sensitivity label of files in SharePoint or OneDrive using PowerShell, you can utilize the PnP PowerShell module or the Microsoft Information Protection (MIP) SDK. Below are the steps and example scripts for both methods.

    Prerequisites

    1. Install PnP PowerShell Module: If you haven't already, install the PnP PowerShell module using the following command:
         
         Install-Module PnP.PowerShell
      
    2. Connect to SharePoint Online: Use the command below to connect to your SharePoint Online site:
         
         Connect-PnPOnline -Url "https://yourtenant.sharepoint.com/sites/yoursite" -UseWebLogin
      

    Using PnP PowerShell

    Change Sensitivity Label for Multiple Files

    You can use the Set-PnPSensitivityLabel command to change the sensitivity label of files in a library. Here's an example script that changes the label for all files in a specific document library:

    
    # Define parameters
    

    Notes:

    • Ensure that the sensitivity label you wish to apply is already created in your Microsoft 365 compliance center.
    • This script assumes you have appropriate permissions to modify labels on these files.

    Using Microsoft Information Protection SDK

    If you need to change labels for files stored locally or if you prefer using a script that interacts more directly with file properties, consider using the MIP SDK. Below is a simplified example of how to apply a sensitivity label using PowerShell:

    
    # Load MIP SDK and necessary assemblies (ensure they are installed)
    

    If required anything please let me know,If answer the helpful please "Accept answer" and "Upvote"

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.