How to get guest users list from Azure AD

HASSAN BIN NASIR DAR 391 Reputation points
2023-02-02T00:27:22.49+00:00

Hi

I have multiple domains in my tenant. I want to get a list of guest users. Please see below example of account, what kind of guest users I want to get.

rambo.jan_test.com#EXT#@abc.onmicrosoft.comm (This is UPN)

I have number of accounts like this in my tenant. Please provide me a powershell cmdlet or script. thanks

Regards

Microsoft 365 and Office Install, redeem, activate For business Windows
Microsoft Security Microsoft Entra Microsoft Entra ID
0 comments No comments
{count} votes

6 answers

Sort by: Most helpful
  1. Sandeep G-MSFT 20,906 Reputation points Microsoft Employee Moderator
    2023-02-02T03:53:14.0033333+00:00

    All guest users in Azure AD will have UPN is the same format that you have mentioned above (rambo.jan_test.com#EXT#@abc.onmicrosoft.com).

    However, you can also use below powershell command to get the desired output that you are looking for,

    Get-AzureADUser -All $true | where {$_.userPrincipalName -like "#EXT#"}

    To run above command, you will need Azure AD module installed.

    If you already have Azure AD module you can follow below steps to get the output,

    • Run command "connect-AzureAD"
    • Enter the Global admin credentials.
    • Now run command Get-AzureADUser -All $true | where {$_.userPrincipalName -like "#EXT#"}
    • You can also run command Get-AzureADUser -All $true -filter "usertype eq 'guest'"

    Let me know if you have any further questions.

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    1 person found this answer helpful.

  2. Khurram Rahim 1,851 Reputation points Volunteer Moderator
    2023-02-08T11:08:26.71+00:00

    You can use the following PowerShell cmdlet to get a list of guest users in your tenant:

    sql

    Copy code

    Get-AzureADUser -Filter "userType eq 'Guest'" | Select-Object DisplayName, UserPrincipalName

    This cmdlet filters the Azure AD users with the userType equals to Guest, and selects the DisplayName and UserPrincipalName properties to be displayed in the output.

    1 person found this answer helpful.
    0 comments No comments

  3. Khurram Rahim 1,851 Reputation points Volunteer Moderator
    2023-02-08T11:16:25.9533333+00:00

    You can use the following PowerShell script to retrieve a list of guest users in your tenant:

    sql

    Copy code

    Connect-AzureAD

    $guestUsers = Get-AzureADMSInvitation -Filter "invitedUserDisplayName ne ''" | Where-Object {$_.InvitedUserEmailAddress -like "#EXT#@"}

    $guestUsers | Select-Object DisplayName,InvitedUserDisplayName,InvitedUserEmailAddress

    This script first connects to Azure Active Directory using the Connect-AzureAD cmdlet. Then, it retrieves a list of all MS invitations using the Get-AzureADMSInvitation cmdlet and filters the list to only include guests users by checking if the InvitedUserEmailAddress property contains the string #EXT#@. Finally, it selects the DisplayName, InvitedUserDisplayName, and InvitedUserEmailAddress properties for each guest user and displays the results.

    1 person found this answer helpful.
    0 comments No comments

  4. Killerbe 50 Reputation points
    2023-06-29T07:34:34.39+00:00

    I wanted to do the same simple task using the Microsoft Graph SDK, however i cannot find any usable info regarding the topic.

    The AzureAD module is being deprecated, and will sees to function on 31 March 2024.

    0 comments No comments

  5. Morgan Thevarajan 0 Reputation points
    2024-11-01T13:55:41.8266667+00:00

    Using https://intune.microsoft.com shouldn't there be a simple way to filter and display only the Guest type of account and then export to XLSX file. I've sent feedback to Microsoft Service Health team.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.