1

I am trying to add metadata to document library folders created using the Add-PnPFolder command. I've been using the Set-PnPListItem command to do this, which requires the folder's list item ID. Using

Get-PnPListItem -List $LibraryName -UniqueId $folder.UniqueId

to retrieve the ID works when the folder is at the root of the library, but fails to return anything for nested folders. I've tried

Get-PnPListItem -List $LibraryName | Where-Object {$_.FieldValues.Title -eq $foldername}

which works, but gets prohibitively expensive as the library grows. Is there a better way to get metadata onto a folder item that I'm unaware of?

1
  • Is it the same metadata for all folders or are there any special cases? May 5 '21 at 5:35
0

Do you mind getting the ID from the SharePoint UI instead of using PnP PowerShell? If no, you can show the OOB ID column in the view.

enter image description here enter image description here If you have a nested folder structure, you can search on the top search box by the folder name and you can easily get the folder ID from UI. enter image description here

1
  • That might be an option, however I have a large number of files to add to this library and am using PnP PowerShell to do so. I'd like to add the metadata via the script and not have to go back and semi-manually tag 1500+ folders. Regardless, thank you for your answer! May 4 '21 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.