Skip to content

How to Use PowerShell to Permanently Delete a User in Office 365

< 1 minute read

blue stack

Say you’ve recently deleted some users in your Office 365 admin console. By default, when you delete a user, that user is placed in the Recycle Bin where their settings live for another 30 days before that user is permanently deleted, kind of like a soft delete.

In the case where you want to delete that user before the 30 days are up, here’s how to use PowerShell to clean your recycle bin.

  1. First, make sure you are connected to PowerShell. This article shows you how to connect Office 365 to PowerShell. 
  2. Once you’ve confirmed you’re connected, type this cmdlet to see the current user profiles that are stored in your deleted folder:
    1. Get-MsolUser – ReturnDeletedUsers
  3. This command will show you all of the users that are currently stored in the Deleted Users/Recycle Bin folder, and have not yet been permanently deleted because 30 days have not passed since they were first put in this folder.
  4. To delete a certain user in that list, say I wanted to expedite the permanent deletion of one of the users returned in this list, I would type in this cmdlet:
    1. Remove-MsolUser -UserPrincipalName “[user’s email address]” -RemoveFromRecycleBin
  5. You’ll be asked to confirm if you definitely want to permanently delete this user.
  6. Type Y for Yes.
  7. You have now successfully deleted that user permanently.
  8. To confirm that it’s been completely deleted, type this cmdlet:
    1. Get-MsolUser-ReturnDeletedUsers
  9. The results returned here should no longer show that user

Click here for more information on these cmdlets relating to deleted user accounts.

Categories

Sign up for our newsletter