Obtaining a list of all users from a tenant based on filter conditions like “country” or “department” is a common task for a Microsoft 365 administrator. While the Microsoft 365 Admin Center or Entra portal can provide a list of all users, they currently lack the feature to apply filters based on specific requirements.
For example, if you need a list of all users belonging to the HR department, the current process requires exporting all users to an Excel sheet and applying a filter on the “Department” column. This can become quite laborious, especially when dealing with a large number of users.
This article will guide you on how to retrieve users based on specific filter conditions using PowerShell and CoreView.
To retrieve Microsoft Entra ID users based on specific filter conditions, you can use the Microsoft Graph PowerShell module. First, ensure that the Microsoft.Graph module is installed and active:
Once connected to Microsoft Graph, you can use various cmdlets to find and manage Entra ID users:
Examples:
Although this is helpful in most scenarios it has certain restrictions when applying the filter conditions on certain properties. For example we cannot use same script to get all the users of a particular domain or users of particular licensed assigned.
With CoreView, you can filter your user list using many different parameters. Let's see the steps to achieve this.
In the same way, you can filter any column based on what you need. After filtering, you can export the results to an Excel file or take action on them directly from the report.
If you prefer to view your filtered data in an aggregator format instead of a table, just enable the “Pivot mode” toggle located in the top left corner. For further information, please visit this article: Pivot mode in reports.