Permanently remove a guest user in Office 365

To permanently delete a guest user in your Office 365, follow the steps below.

(1) Check that the account is still active

If your guest user email address is : user1@domain.com then his UserPrincipalName is user1_domain.com#EXT#@tenant.onmicrosoft.com

To check that the guest is still active, use the command lines below

$A = user1_domain.com#EXT#@tenant.onmicrosoft.com
Get-MsolUser -UserPrincipalName $A

GuestExist

(2) How to delete guest user 

Remove-MsolUser -UserPrincipalName $A

RemoveGuest1

(3) Check that guest user account is present in recycle bin

Get-MsolUser -All -ReturnDeletedUsers | ? {$_.userPrincipalName -eq $A}

GuestAlreadyInRecycleBin

(4) How to permanently remove the guest account

Remove-MsolUser -UserPrincipalName $A -RemoveFromRecycleBin

RemoveGuestFromRecycleBin

Voilà 🙂

2 thoughts on “Permanently remove a guest user in Office 365

Add yours

  1. When I run this command: Get-MsolUser -All -ReturnDeletedUsers | ? {$_.userPrincipalName -eq $A}

    It returns the GUEST account that I deleted. However, when I run this command: Remove-MsolUser -UserPrincipalName $A -RemoveFromRecycleBin

    I gives this error:
    Remove-MsolUser : User Not Found in the Microsoft Online directory Deleted Users container.

    Like

Leave a reply to Kevin B Cancel reply

Blog at WordPress.com.

Up ↑