I need to export the list of users in Azure with their respective network group + email + UPN and need to export to Storage Account

Michael Mimbela Arenaza 41 Reputation points
2022-09-07T16:26:34.333+00:00

Hi Team,
I need to export the list of user in Azure with their respective network group + email + UPN and need to export to Storage Account in format csv file via PowerShell command, because we pretend use Automation Acounts for that.

I have tried with this commands:

Get-AzureAdGroup -Filter "startswith(DisplayName,'XXX_')" -->this output give us the Network group that we want
Get-AzADUser -->this output give us all the Users in Azure Active directory

But we don't want all users, we want just the users in the Network Group filtered

below I attached the example of the report.

Note: In my prod Env we have more than 50,000 users and more than 500 network groups aprox.

238679-print-model.png

Regards

Windows for business | Windows Server | User experience | PowerShell
Microsoft Security | Microsoft Entra | Microsoft Entra ID
Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Vasil Michev 119.5K Reputation points MVP Volunteer Moderator
    2022-09-07T17:25:15.893+00:00

    Use the Get-AzureADGroupMember cmdlet?

    Get-AzureAdGroup -Filter "startswith(DisplayName,'XXX_')" | Get-AzureADGroupMember  
    

    Optionally, add a filter for just users:

    Get-AzureAdGroup -ObjectId ecdbc965-b30b-47d7-8dbe-904fd286aa46 | Get-AzureADGroupMember | ? {$_.ObjectType -eq "User"}  
    

  2. Sandeep G-MSFT 20,906 Reputation points Microsoft Employee Moderator
    2022-09-19T07:27:49.057+00:00

    @Michael Mimbela Arenaza

    As you mentioned that you are getting an error while executing below script,
    Get-AzureAdGroup -ObjectId ecdbc965-b30b-47d7-8dbe-904fd286aa46 | Get-AzureADGroupMember | ? {$_.ObjectType -eq "User"}

    As per the error you are getting permission issues. You can connect to AzureAD using Global admin credentials.

    Global admin account is the account with highest privileges in Azure AD.

    Let me know if you are still getting some error.

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


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.