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
- Install PnP PowerShell Module: If you haven't already, install the PnP PowerShell module using the following command:
Install-Module PnP.PowerShell
- 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"