Delete User OneDrive permanent and immediately

40 views Asked by At

i want to create a automatically script which delete a OneDrive of a user account permanent and immediately.

the Powershell cmdlet is:

Remove-SPOUser -Site 

the problem with this cmdlet is that you cannot run it in a powershell az function because you can not provide application id and client secret / certificate

also no graph api call is provided to run this operation.

is there still a way to autmate this?

1

There are 1 answers

0
Amy Jiang_MSFT On

According to the article Restore a deleted OneDrive, there is currently no way to achieve what you say. The recommended way to delete a OneDrive is to run the following command after you have recovered the data you need from it:

Remove-SPOSite -Identity <URL>

Remove-SPODeletedSite -Identity <URL>

However, this will not permanently and immediately delete the OneDrive. Instead, it will move it to the SharePoint recycle bin, where it will be retained for a period of time before being permanently deleted.

It is important to note that there is no way to bypass this retention period and immediately delete the OneDrive. If you need to ensure that the OneDrive is permanently deleted, you will need to wait for the retention period to expire.