[SPO] Delete document library folder and its contents using PNP PowerShell (V2)
OK, so these days one of my site’s visitors (thanks Alice) mentioned that my previous script to delete document library folder contents using PNP from [ […]
OK, so these days one of my site’s visitors (thanks Alice) mentioned that my previous script to delete document library folder contents using PNP from [ […]
So here goes: Source: Shared Documents Destination: TargetDOCLIB
|
1 2 3 4 5 6 7 8 9 10 |
Connect-PnPOnline -Url "https://tenant.sharepoint.com/sites/testsite1" -Interactive $allItems = Get-PnPListItem -List "Shared Documents" -FolderServerRelativeUrl "/sites/testsite1/Shared Documents" foreach ($item in $allItems) { if ($item.FileSystemObjectType -eq "File") { Write-Host "Copying file: $($item.FieldValues.FileLeafRef)" -ForegroundColor green Copy-PnPFile -SourceUrl "$($item.FieldValues.FileRef)" -TargetUrl ("/sites/testsite1/TargetDOCLIB/"+$item.FieldValues.FileLeafRef) -Overwrite -Force } } |
Enjoy!
Copyright © 2026 | PhoeNIXBird Networks