PnP-PowerShell
PnP-PowerShell copied to clipboard
Setting a label to a folder by a cmdlet
###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:###
-
Are you using
Apply-SPOProvisioningTemplate
orGet-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. - 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.
- 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
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
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.
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?
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