Onedrive files - user without licens

Torben Andersen 0 Reputation points
2024-08-30T16:27:16.9266667+00:00

Hi,

When I remove an E3/E5 license from a user data from SharePoint Online/Onedrive is not deleted.

When you remove the license, all that user's data is held for 30 days. You can access the data, or restore the account if the user comes back. After 30 days, all the user's data (except for documents stored on SharePoint Online) is permanently deleted from Microsoft 365 and can't be recovered.

I believe I have lots of data in Onedrive from users who are still in Entra ID - users who had an licens but no longer has an licens. I would like to delete all onedrive data from these users. How to do that is an easy way?

OneDrive
OneDrive
A Microsoft file hosting and synchronization service.
1,142 questions
0 comments No comments
{count} votes

5 answers

Sort by: Most helpful
  1. Jiajing Hua-MFST 10,805 Reputation points Microsoft Vendor
    2024-09-02T05:45:36.9333333+00:00

    Hi @Torben Andersen

    You can permanently delete the OneDrive by running the following commands:

    Remove-SPOSite -Identity <URL>

    Remove-SPODeletedSite -Identity <URL>

    To run the commands, please download the latest SharePoint Online Management Shell, and connect to SharePoint as a SharePoint Administrator in Microsoft 365.

    For more, please refer to: https://learn.microsoft.com/en-us/sharepoint/restore-deleted-onedrive

    Please note, when you permanently delete a OneDrive, you will not be able to restore it.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    0 comments No comments

  2. Torben Andersen 0 Reputation points
    2024-09-02T17:29:38.6466667+00:00

    Hi @Jiajing Hua-MFST

    Thanks a lot for your answer

    How can I get the URL for all the users who don't have a license?

    0 comments No comments

  3. Jiajing Hua-MFST 10,805 Reputation points Microsoft Vendor
    2024-09-03T09:22:04.0666667+00:00

    Hi @Torben Andersen

    Thanks for your back.

    Based on my tests, to get the unlicensed OneDrive account URLs, you can use PnP PowerShell (Get-PnPUserProfileProperty) via specifying user's email accounts in .csv file.

    The following image is the .csv file of my sample. You may list user accounts that be removed licenses in a .csv file.

    User's image

    Then run the code like below as a SharePoint admin. Please note, you need to replace "domain" with yours.

    #Parameters
    $SiteURL = "https://domain-admin.sharepoint.com"
    $CSVFile = "C:\Users\test2\Desktop\UserAccount.csv"
    #Connect to PnP Online
    Connect-PnPOnline -Url $SiteURL -Interactive
    #Get the data from CSV file
    $CSVData = Import-CSV $CSVFile
    $Counter =1
    #Loop through each Row in the CSV file and upload file to SharePoint
    ForEach($Row in $CSVData)
    {
        Get-PnPUserProfileProperty -Account $Row.useraccount -Properties 'PersonalUrl'
        $Counter++
    }
    
    

    Then you will get the URLs like following image.

    User's image

    For more, please refer to this link: https://learn.microsoft.com/en-us/sharepoint/list-onedrive-urls

    You can also export reports via going to SharePoint Admin Center. Click Reports > OneDrive accounts, go to Unlicensed OneDrive accounts section, then click "Download report". Please note, the accounts listed in this report are updated weekly, have been unlicensed for more than 90 days.

    The reference: https://learn.microsoft.com/en-us/sharepoint/unlicensed-onedrive-accounts


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



  4. Torben Andersen 0 Reputation points
    2024-09-14T11:30:54.42+00:00

    Hi @Jiajing Hua-MFST

    Thanks a lot for your input, sorry for my late respons.

    I will test your solution and give you respons with a week or two.

    0 comments No comments

  5. Torben Andersen 0 Reputation points
    2024-09-24T17:20:21.3366667+00:00

    Hi @Jiajing Hua-MFST

    I get this error messageOnedrive


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.