Forum Discussion
Setting Retention Labels on OneDrive Folder items.
Hi
I am in the process of reviewing the retention label of user's ODFB files after each file is restored from the Recycle bin .
I can locate my file
$f = Get-PnPFolderItem -FolderSiteRelativeUrl "Documents/Expenses" -ItemName $filename
However, I am short changed here 😑, as there are no SetComplianceTag methods available, as per Get-PnPListItem (see below) . Hence, is there a clever way to locate this file and pipe the output to Get-PnPListItem , to allow me to access these methods.
SetComplianceTag
SetComplianceTagWithExplicitMetasUpdate
SetComplianceTagWithHold
....
Update: remembered that James from @IDLive had written a similar query in some auditing scripts, plus there a load of CAML examples out there to https://sharepoint.stackexchange.com/questions/35571/caml-query-to-get-listitem-by-name-field. So real easy to create my query from these resources that worked first time ( a first for me 😃)
$query = "<View Scope='RecursiveAll'><Query><Where><Eq><FieldRef Name='FileLeafRef'/><Value Type='File'>$filename</Value></Eq></Where></Query></View>"
$f = Get-PnPListItem -List Documents -Query $query
1 Reply
- Daniel WesterdaleIron Contributor
Update: remembered that James from @IDLive had written a similar query in some auditing scripts, plus there a load of CAML examples out there to https://sharepoint.stackexchange.com/questions/35571/caml-query-to-get-listitem-by-name-field. So real easy to create my query from these resources that worked first time ( a first for me 😃)
$query = "<View Scope='RecursiveAll'><Query><Where><Eq><FieldRef Name='FileLeafRef'/><Value Type='File'>$filename</Value></Eq></Where></Query></View>"
$f = Get-PnPListItem -List Documents -Query $query