PnP-PowerShell icon indicating copy to clipboard operation
PnP-PowerShell copied to clipboard

Setting a label to a folder by a cmdlet

Open jaumeg3 opened this issue 5 years ago • 4 comments

###Notice: many issues / bugs reported are actually related to the PnP Core Library which is used behind the scenes. Consider carefully where to report an issue:###

  1. Are you using Apply-SPOProvisioningTemplate or Get-SPOProvisioningTemplate? The issue is most likely related to the Provisioning Engine. The Provisioning engine is not located in the PowerShell repo. Please report the issue here: https://github.com/officedev/PnP-Sites-Core/issues.
  2. Is the issue related to the cmdlet itself, its parameters, the syntax, or do you suspect it is the code of the cmdlet that is causing the issue? Then please continue reporting the issue in this repo.
  3. If you think that the functionality might be related to the underlying libraries that the cmdlet is calling (We realize that might be difficult to determine), please first double check the code of the cmdlet, which can be found here: https://github.com/OfficeDev/PnP-PowerShell/tree/master/Commands. If related to the cmdlet, continue reporting the issue here, otherwise report the issue at https://github.com/officedev/PnP-Sites-Core/issues

Reporting an Issue or Missing Feature

A Cmdlet for setting a label when you create/set a folder.

Expected behavior

A Cmdlet like "Set-PnPDefaultColumnValues" but for the folders for changeing/add a value.

Actual behavior

Not implemented yet.

Steps to reproduce behavior

Not implemented yet.

Which version of the PnP-PowerShell Cmdlets are you using?

  • [ ] PnP PowerShell for SharePoint 2013
  • [ ] PnP PowerShell for SharePoint 2016
  • [X] PnP PowerShell for SharePoint Online

What is the version of the Cmdlet module you are running?

3.13.1909.0 SharePointPnPPowerShellOnline Module

How did you install the PnP-PowerShell Cmdlets?

  • [ ] MSI Installed downloaded from GitHub
  • [X] Installed through the PowerShell Gallery with Install-Module
  • [ ] Other means

jaumeg3 avatar Sep 20 '19 15:09 jaumeg3

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

ghost avatar Sep 20 '19 15:09 ghost

Hi @jaumeg3,

Are you referring to Retention Labels (Compliance Tags)? You can now use Set-PnPListItem to set a label on a list item e.g. Set-PnPListItem -List "Documents" -Identity 1 -Label "My Label"

If you set this on a folder it acts as a default label for any items added inside the folder.

Edit: it's not in the documentation but the Label parameter is there in the latest version of PnP PowerShell.

danielcecil avatar Sep 25 '19 08:09 danielcecil

Hi @danielcecil . I am working with Set-PnPLabel Just now and it appears as the cmdlet describes, it "Sets a retention label on the specified list or library" not the folders within.

As an example, I am attempting to set the "Documents Folder" and another few folders within Documents in OneDrive. Below are a few example commands.

Set-PnPLabel -List "Documents" -Label "OneDriveDefault" Set-PnPLabel -List "Documents/Recipes" -Label "Recipes" Set-PnPLabel -List "Documents/Photos" -Label "Photos"

If I run these three commands within a script in the above order, all 3 folders get the label "Photos"

If I were to switch the order:

Set-PnPLabel -List "Documents/Recipes" -Label "Recipes" Set-PnPLabel -List "Documents/Photos" -Label "Photos" Set-PnPLabel -List "Documents" -Label "OneDriveDefault"

All folders would have the label "OneDriveDefault".

I expect this is why @jaumeg3 is asking for a way to set a label to a folder. It would seem the targets the root of the library only.

Have you or any other found away to set a label on folders nested within a library at all?

AlanPS1 avatar Nov 11 '20 22:11 AlanPS1

To reference my previous post, I have found a solution to the issues I was having.

Please see Set-PnPLabel doesn't appear to be working, am I wrong?

Whilst this isn't the dedicated cmdlet solution the OP was looking for, it is a solution to applying a label to a subfolder so I thought I'd post it incase it is helpful for someone.

Thanks, Alan

AlanPS1 avatar Nov 16 '20 17:11 AlanPS1