365tips.be

The best Microsoft 365 tips on the web

How to delete a user in Office 365 (hard and soft delete)

Sometimes you want to hard-delete users if, for example, you have duplicate accounts and have started a new synchronization from Active directory. In addition, sometimes it is convenient to do a hard-delete and then restore the mailbox to another user. In this blog a short guide you how to perform a hard-delete in Office 365 via Powershell.

Install the MSOnline module to connect to Microsoft Online

Install-Module -Name MSOnline

Connect to Azure AD via PowerShell

Connect-msolservice

Press your username & password.

Remove your user from Office 365

Retrieve the deleted users via PowerShell

Get-Msoluser -ReturnDeletedUsers

Delete all users that are in -ReturnDeletedUsers?

Get-MsolUser -ReturnDeletedUsers | Remove-MsolUser RemoveFromRecycleBin

Delete only this user?

Get-MsolUser -ReturnDeletedUsers | fl id
Remove-MsolUser -RemoveFromRecycleBin -ObjectId 5ed439d0-ffbe-43a3-8f89-e168f07ef66f

The user has been deleted

Tagged: , ,
0 0 vote
Article review
Subscribe
Please let us know if there are
guest

0 Comments
Inline feedbacks
See all comments
0
Would love to know your thoughts, please leave a comment.x