User not in directory, External access issue on SharePoint Online

Overview

User can’t be found in the tenant.sharepoint.com directory. This is a common issue when your external users have accepted the invitation email with the link by using another email(that differs than the one that was invited) to log on your tenant. Then now he is trying to access by using the one was invited. That will be a problem with access.

 
When you invite/share something in SharePoint Online with someone outside your organization. SharePoint Online will store the emails once it sends out the invitation. So when the invited external user accepted the invitation and log on your SharePoint tenant with an email that differs than the one that was invited. This email will be marked as login credential for the invitation email. For instance, you invite/share something on your SharePoint tenant with [email protected]. When this user received the invitation email, he/she clicks on the link in the email and login with his/her personal email, such [email protected]. So it means that [email protected] on your SharePoint tenant will have the login credential is [email protected], not [email protected].
If you try to invite/share the user [email protected] to any other contents on your SharePoint tenant again, they also have to use the login credential [email protected]
If you run the power-shell command to get the information about the external user, you will see something like a picture as below:
Get-SPOExternalUser

Resolution

Okay so, how to resolve it? There are two steps to accomplish it (the order of steps doesn’t matter)
First, you need to remove the user, for example, [email protected], from SharePoint front-end by following below steps or this article:

Delete selected users from site collection
Second, use SPO PowerShell to remove the user from your tenant:

  • Connect to your SharePoint tenant by following below command then enter your tenant admin credential

Connect-SPOService -Url https://tenant-admin.sharepoint.com -credential [email protected]

  • Get User’s UniqueID by running

    Get-SPOExternalUser

  • Delete user by running

    Remove-SPOExternalUser -UniqueIDs {id}

Delete external user
Finally, do re-invite the user again. then you should good to go.