Reputation: 75
I am working with Azure AD and need to get all users and export it into csv file and finally put it into SQL.
At this moment we have about 10,000 users. The problem is the PowerShell command [Get-AzureADUser – ALL] it’s SUPER SLOW!! It takes about 58 minutes to complete the task. Today we noticed that some users made changes to their account. I need to update the whole list to find the changes made.
1) Is there a faster way I can get ALL users?
2) How can I only find users who made changes to their account?
Powershell script:
$aadUsers = Get-AzureADUser -All $true | Select DisplayName, ObjectId, userType,GivenName
Upvotes: 1
Views: 16058
Reputation: 1
Get-msoluser -all | select DisplayName, ObjectId, userType, FirstName
Get-msoluser -all | select *
Get-msoluser -all | Where {$_.city -eq 'chicago'}
This module seems quite a bit faster.
Upvotes: 0
Reputation: 23141
According to my research, if we want to get the users' changes, we have two ways to do that
Track changes to users with Users audit logs.
We can use Azure AD Powershell command Get-AzureADAuditDirectoryLogs
to get Users audit logs. For more details, please refer to https://learn.microsoft.com/en-us/powershell/module/azuread/get-azureadauditdirectorylogs?view=azureadps-2.0-preview
Install-module AzureADPreview
Connect-AzureAD
Get-AzureADAuditDirectoryLogs -All $true -Filter "Category eq 'UserManagement' and result eq 'success'"
Get https://graph.microsoft.com/v1.0/users/delta
For example
GET https://graph.microsoft.com/v1.0/users/delta?$select=displayName,givenName,surname
If your response is too big, it will return @odata.nextLink
in the response. Then you can directly use the link to get the next page response. At the last page response, it will return @odata.deltaLink
in the response. You can save it and directly use the link to get the changes in next time. For more details, please refer to https://learn.microsoft.com/en-us/graph/delta-query-users
Upvotes: 1