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

Set-PnPLabel -- -SyncToItems $true not changing the setting for applying to existing documents

Open dragonraelms opened this issue 7 years ago • 7 comments

Reporting an Issue or Missing Feature

When using the parameter -SyncToItems and setting the value to $true or 1. The setting "Apply label to existing items in the library" isn't changed and items within the folder don't have their labels updated

Expected behavior

when setting the parameter to true I'd expect the list setting "Apply label to existing items in the library" to show true and the labels on items to be updated

Actual behavior

Nothing changes and everything remains unticked

image

Steps to reproduce behavior

Please include complete code samples in-line or linked from gists Connect to an office 365 sharepoint site and run: Set-PnPLabel -List "Test" -Label "sp test" -SyncToItems $true

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.5.1901.0

How did you install the PnP-PowerShell Cmdlets?

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

dragonraelms avatar Jan 24 '19 16:01 dragonraelms

Has their been any update to this issue? Still having the same problem described above. Thanks.

edhild avatar Apr 09 '19 20:04 edhild

Bumping on this thread as I referenced an issue that was created on office-docs-powershell repo about the same thing described here.

get-itips avatar May 17 '19 12:05 get-itips

Hi, Is there any update on this issue? I have dowloaded the latest version of PnP but this issue still exists.

KashifMajeed24 avatar Jul 19 '19 20:07 KashifMajeed24

Any update on this issue? The issue still exists.

joannecklein avatar Aug 29 '19 21:08 joannecklein

Hi joannecklein,

No response on this. I ended up writing a PowerShell code which works fine!

Not going to post the whole code but just to give you an idea, add Microsoft.Office.Client.Policy.dll assembly, connect to SharePoint site, create client context object, declare required variables and use the following code

$list = $context.Web.Lists.GetByTitle($listName) $context.Load($list) $context.Load($list.RootFolder) $context.ExecuteQuery()

$listUrl = $list.RootFolder.ServerRelativeUrl [Microsoft.SharePoint.Client.CompliancePolicy.SPPolicyStoreProxy]::SetListComplianceTag($context,$listUrl,$defaultLabel,$false,$false,$true) $context.ExecuteQuery()

I hope this helps you and the others!

KashifMajeed24 avatar Aug 30 '19 11:08 KashifMajeed24

Thanks KashifMajeed24 ! This helps a lot... thank you very much! I also came across this TechCommunity post to address the programmatic setting of it: https://techcommunity.microsoft.com/t5/Microsoft-SharePoint-Blog/Scripted-Application-of-Data-Governance-Labels/ba-p/242412

joannecklein avatar Aug 30 '19 19:08 joannecklein

Sorry for the delay in response, was not aware of this issue.

The cmdlet is now being fixed, it was stupid mistake from my side (passing in the wrong variable in the call)

Please note that the checkbox in the UI page will never be set properly, even using the UI checkbox does not remain checked. Though, the functionality works regardless of this checkbox value.

robinmeure avatar Sep 04 '19 10:09 robinmeure