Deleting MSOL user using PowerShell

March 24, 2018 | by iaur | posted as Adminstration, Microsoft 365

Scenario

  • You want to delete user using PowerShell
  • You want to purge delete user from the recycle bin

Steps

  1. Connect to MSOL using PowerShell
  2. Run below command as desired
Remove-MsolUser -UserPrincipalName ‘DemoUser5@Priasoft.mail.onmicrosoft.com’ -RemoveFromRecycleBin
This cmdlet will delete user and purge it from the recycle bin. Replace DemoUser with the UPN of your target user
Get-Msoluser -ReturnDeletedUser |fl
This cmdlet will display ALL users that are on the recycle bin
Get-Msoluser -ReturnDeletedUser |select UserPrincipalName
This cmdlet will sort ALL soft-deleted users by UPN
Get-Msoluser -ReturnDeletedUser | Remove-MsolUser -RemoveFromRecycleBin -Force
This cmdlet will force delete ALL users found in the recycle bin

Force delete DirSynced User

Get-msoluser -UserPrincipalName ‘ron@faceresionem.onmicrosoft.com’ | Remove-MsolUser -Force | Remove-MsolUser -RemoveFromRecycleBin
example user is ron
-UserPrincipaIName . com 
PS C: \ 
Get -msoluser 
-RemoueFromRecycIe8in 
emoue-MsoILlser 
Remoue-MsoILlser 
PS C: \ 
PS C: \

Feedback or Help?

Should you have one, click here

Boring Ads. Pardon me :)