How to get guest users list from Azure AD

HASSAN BIN NASIR DAR 306 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
Microsoft 365
Formerly Office 365, is a line of subscription services offered by Microsoft which adds to and includes the Microsoft Office product line.
3,787 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,473 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Sandeep G-MSFT 14,486 Reputation points Microsoft Employee
    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,841 Reputation points
    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,841 Reputation points
    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 45 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