Today In this post, I’ll show you how to get the list of guest users added to your tenant Office 365 Users. And then I'll show you how to remove the non-required guest users from the list. I have covered how to use Microsoft Graph API to control Office 365 data using Microsoft Graph Explorer in my previous articles.
Guest users are an external user and they are not part of your organization. They get added after they get an invite from you or other people from your organization.
Invitations occur through sharing some files or sites to their email id or adding them to any Office 365 group. You can also control the guest users from Office 365 Admin center. Let’s follow the below steps in Microsoft Graph Explorer to view and remove the guest users.
View the Guest Users
- Navigate to the Microsoft Graph Explorer using aka.ms/ge
- Then login to the tool using the button called Sign in with Microsoft.
- Select GET operation.
- Select any version v1.0 or beta from the Request dropdown
- Enter the below Microsoft Graph API endpoint
https://graph.microsoft.com/v1.0/users?$filter=userType eq ‘Guest’
- Ensure at least any of the below permission scope is consented,
User.ReadBasic.All, User.Read.All, User.ReadWrite.All, Directory.Read.All, Directory.ReadWrite.All, Directory.AccessAsUser.All
- Click Run Query button.
- Under the Response Preview, we can see all the guest users added to your tenant.
- Copy any of the Users Ids from the response. We must use that ID to remove from the list.
- Select DELETE operation from the operation dropdown,
- Select any version v1.0 or beta from the Request dropdown
- Enter the below Microsoft Graph API endpoint
https://graph.microsoft.com/v1.0/users/<user id>
- Ensure the below permission scope is consented,
Directory.AccessAsUser.All
- Click the Run Query button. Now the requested guest user is removed from the Office 365 tenant.
We have learned how to fetch all the guest users from the tenant and how to remove them using Microsoft Graph Explorer.