Setting Retention Labels on OneDrive Folder items.

Regular Contributor




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 :expressionless_face:, 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.  









1 Reply
best response confirmed by Daniel Westerdale (Regular 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 get a list item.  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