Introduction
Site classification in SharePoint online is one of the governance features that will help manage the information stored on the SharePoint site, follow certain guidelines, and implement policies to protect the privacy of the content being stored. For instance, if the content has personal information like a customer's bank account, you might want to restrict such content on public sites.
During the site creation process via SharePoint Admin Center, there is an option to define the site sensitivity. Below is the screen capture for reference. However,
![SharePoint Admin Center]()
However, when trying to create the site via PowerShell, there is no parameter to define sensitivity. We can update the site sensitivity after the site gets created.
This article focuses on updating the site sensitivity to a bunch of sites loaded from a CSV file and then showing the status in the console. Thanks to Sujith Nambiar for helping during this script creation process.
Pre-requisites
To run the script successfully,
- The account running the script 'SharePoint Admin' Rights and 'Global Reader rights'.
- PnP PowerShell Module 2.5.0 or greater needs to be installed
- Exchange Online Management module to have version 3.4.0 or above
- Your laptop should have PowerShell 7, aka PowerShell Core
- The schema CSV should have DestinationSite and Classification as the first line header.
![DestinationSite]()
Note. This script is tested on a Windows 10 machine. The same script should work on other OS as PowerShell core is a cross-platform tool.
Steps
Step 1. Get the required modules Imported.
- Exchange Online Management
- PnP PowerShell
Step 2. Store the account credentials in a variable $Creds.
Step 3. Connect to IPPS (Information Protection PowerShell Session). IPPS is a sub-module from the Exchange Online Module. Once the Exchange Online Module is imported, you should be able to connect to the IPPS session using the below command. Connect to the PnP PowerShell session using the admin account credentials.
Step 4. Apply the sensitivity of the PowerShell command to support only the GUID of the Classification. I have written the PS methods below.
- GetSensitvityName: To get the Site Classification name based on the GUID.
- GetSensitivityID: To get the Site Classification ID based on the Display Name.
Step 5. Check if the site has already applied for Site Classification. If it already exists, proceed to the next record, and update the status in the console.
Step 6. Validate if the sites have the right classification applied. You can check it by going to the site and then clicking on ‘Site Information’.
![Site Information]()
Complete Script
Conclusion
Thus, in this article, we have seen how to successfully apply site classification for SharePoint online sites using PnP PowerShell.
Reference