Apply Sensitivity Labels To SharePoint Site, Teams, And Microsoft 365 Groups

Sensitivity labels are information protection policies. These labels can be customized by the organization. We all would have seen sensitivity labels across our mails and files.

You can also apply sensitivity labels to SharePoint Site, Teams, and Microsoft 365 Groups. Now let me tell you how you can do that.

If you have a SharePoint Site which is (Microsoft 365 Group connected) and Teams which is created from SharePoint site (Microsoft 365 Group connected), then you can apply sensitivity labels in simple steps using PowerShell script which you can then automate by adding it in Runbooks or in any terminal with (.ps1) extension

PowerShell Code to apply sensitivity Labels,

#Install Exchange Online Module
Install-Module ExchangeOnlineManagement -Scope CurrentUser

#Connect to Exchange Online PowerShell Module with the user login using Get-Credential
$UserCredential = Get-Credential 
Connect-IPPSSession -Credential $UserCredential

#Get Sensitivity Label GUID for the Label. In this example I have added Confidential as Label Name. Make sure you use Label name as added in your Sensitivity Labels list
#You can also get all the Labels by running the command Get-Label
$label = (Get-Label -Identity "Confidential").Guid

#Disconnect Exchange Online
Disconnect-ExchangeOnline

#Connection to PnPOnline to apply senisitity label to the Group connected SharePoint site also if this site is teamifed the label will also be applied to that Team
$connection = Connect-PnPOnline -Url <SiteURL> -UseWebLogin
Set-PnPTenantSite -Identity <SiteURL> -SensitivityLabel $label -Connection $connection

#Disconnect PnPOnline
Disconnect-PnPOnline

Once you run the script validate the applied Sensitivity Labels by going to the SharePoint site

Apply Sensitivity Labels To SharePoint Site, Teams, And Microsoft 365 Groups
Fig 1.1 – Sensitivity Label applied to the SharePoint Site

Apply Sensitivity Labels To SharePoint Site, Teams, And Microsoft 365 Groups
Fig 1.2 – Sensitivity Label applied to the Team created from the SharePoint site

If you navigate to Azure portal: https://portal.azure.com > Azure Active Directory > Groups > search for the group on which SharePoint site is created, In most cases, the site name is the group name. You will see the group details which will show the Sensitivity Label applied to that group just as shown in Fig 1.3

Apply Sensitivity Labels To SharePoint Site, Teams, And Microsoft 365 Groups
Fig 1.3 – Sensitivity Label applied to the Microsoft 365 Group – Visible in AAD (AzurePortal)

I hope you enjoyed learning something new about applying sensitivity Labels to your Groups, Site, Teams

Keep Learning! Keep Sharing!


Similar Articles