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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: