Вопрос

I am looking for a simple method (possibly a PowerShell script) that will completely empty OneDrive recycle bins (incl. the secondary recycle bins) within a given URL [tenant]-my.sharepoint.com/personal/[username]; one user at-a-time is an okay solution, as we only need to do this in certain circumstances. I tried using SPO Management Shell, but the app told me that the OneDrive locations are not managed paths within SPO. Using the online interface will only handle 200 files at a time, with a 30 second processing time in between; sometimes we have upwards of 10,000 files in these recycle bins to remove, so this is not an appropriate method. Any ideas are appreciated. Thank you, in advance!

Это было полезно?

Решение

Just like willman said, use a script like the one below will clear all files in recycle bin.

$adminUPN="user account"
$userCredential = Get-Credential -UserName $adminUPN -Message "Type the password."
Connect-PnPOnline -Url <https://tenant-my.sharepoint.com/personal/username account> -Credentials $userCredential
Clear-PnPRecycleBinItem -All -force

the url in Connect-PnPOnline is the OneDrive URL

Другие советы

Clear-PnPRecycleBinItem with the Identity parameter set will delete a single specific item from the recycle bin (documentation here), and the -All parameter will delete all the items in the current site collection's recycle bin.

So assuming your script is running under a user account with the correct privileges, it should be able to connect-pnponline with the -url of the desired OneDrive, and clear it's recycle bin.

If you haven't used PnP PowerShell yet, the documentation starts here.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с sharepoint.stackexchange
scroll top