Forum Discussion

MS1977's avatar
MS1977
Copper Contributor
Apr 11, 2025

PowerShell commands to adjust Sensitivity Labels in SharePoint

Hi Everyone

Can someone please help me with this? I am trying to adjust the sensitivity labels of existing contents inside a SharePoint subfolder using PowerShell.  I have so far managed to capture the contents in the subfolder to a variable using the below commands but I don't know which commands I can use in the foreach statement to apply the labels. 

 

Connect-PnPOnline -Url "https://xxxx.sharepoint.com/sites/xxxxx" -Interactive -ClientID xxxxxxxxxxxxx

 

$Items = Get-PnPListItem -List Documents -FolderServerRelativeUrl "/sites/xxxx/Shared Documents/xxxxxx"

 

foreach ($item in $items) { ???????????????????? -label "xxxx" }

 

I tried the Set-PnPLabel label but looks like this command is only for retention Labels.  Any help would be highly appreciated.

 

Thanks in advance -MS1977

 

3 Replies

  • MS1977's avatar
    MS1977
    Copper Contributor

    Thank you all. nikkichapple Can you please tell me how I can use this command in my script. My testing is showing that this command doesn't accept wildcard. 

  • You're on the correct track, and yes Set-PnPLabel is for retention labels, not sensitivity labels.

    Sensitivity labels aren't addressed via PnP PowerShell for SharePoint Online content, since sensitivity labels for files are handled differently, but you can use auto-labeling policies in Microsoft Purview.

    See Here

     

    Best 

    Ahmed Masoud

    Linkedin

Resources