Were are going to be using Office 365 labels to control retention of our SharePoint documents.

I’m trying to add the “Labels” column to every document library view so that users can see which retention they have assigned to which documents.

It seems that the only way to do the existing sites (300+) is to use PowerShell? Is there an easier way that I am missing?

How would I do it for any new document libraries created after the script has been run?

enter image description here


You can do this without Powershell using Security and Compliance Centre. More details here

  1. Create Labels
  2. Publish the created Label (it might take a day for these labels to appears in the libraries
  3. Under List Setting -> Apply a label to items in this library

Here are the screenshots:

Security and Compliance Centre - Classification enter image description here Document Library - List Settings enter image description here Ability to auto apply label to everything in the library enter image description here

PowerShell to add column to all the documents libraries view in multiple site collection - Note: Modern/Office 365 Group sites are not included in this:

Use the function provided here, but replace the section with the following to apply to all the site collections. If you want to learn more about pnp powershell

$sites = Get-PnPTenantSite
foreach($site in $sites){

$ViewName="All Documents"
Connect-SPOnline -Url $site.Url -Credentials $o365
ModifyView -web $web -ViewName $ViewName -Columnname $Columnname 

  • Thank you for this, we have around 300 sites with lots of document library’s, is there any way to automate this? (I’ve added a bit more detail to my original post) – Chris Taverner Oct 24 '17 at 18:55
  • I am not sure which part you would like to automate... creation of label, apply the labels to documents or adding labels to document libraries? If you create the label and publish it through Security and Compliance centre it will appear in all the sites across the tenant. The label column is automatically created. – SharePointer Oct 24 '17 at 19:35
  • I’d like to automate adding the “labels” column to all document libraries views. By default it doesn’t show, so the user has to check each document to see what the retention / label is. I’ve added a screenshot to my original post. Thank you for your help :) – Chris Taverner Oct 24 '17 at 19:37
  • I am afraid, PowerShell is your friend to deal with Views. Here is the script that can help. I have tested this script and it is straightforward but per site collection. I think this can be automate for all the site collections techcommunity.microsoft.com/t5/SharePoint/… – SharePointer Oct 24 '17 at 20:05
  • I have update my answer with the script. If you want to do the same for the Office 365 Groups, please let me know as I have a script ready for that also. – SharePointer Oct 24 '17 at 20:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.