I have a directory that has about 200k users in it. I need to pull back all the users that came from on-prem AD. This of course would exclude the multiple source guest users. I have to use source because not all users have a usertype.
If there was a way to search Department not equal to null that would work as well, but it doesn't appear to be part of the odata filter standard.
Get-AzureADUser -Filter "Department eq ''" | select DisplayName,`
UserPrincipalName,Mail,creationType,AccountEnabled,Department
To get users that come from on-prem AD you could do something like this
Get-AzureADUser -Filter "dirSyncEnabled eq true"
For selecting only a few, other operators like top can be used as well.. e.g.
Get-AzureADUser -top 5 -Filter "dirSyncEnabled eq true"
To get all users one shot you can do
Get-AzureADUser -All $true -Filter "dirSyncEnabled eq true"
or
Get-AzureADUser -all $true | where-object -property DirSyncEnabled -eq "True"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With