Forum Discussion

Teijo Hämäläinen's avatar
Teijo Hämäläinen
Copper Contributor
Apr 29, 2019

How to list users synced from onprem AD and cloud-only users?

Hello guys!

 

I was tasked to list users synced from onprem AD and cloud only users

 

I have downloaded and imported AzureAD PS module 2.0.2.16

 

Azure portal shows several users with source 'Azure Active Directory'.

 

I'm first trying to list these cloud-only users by running a command command  Get-AzureADUser | where {$_.dirsyncenabled -eq $false} but it yields only one user when there should be a lot more.

 

I also need to list users synced from onprem AD.

 

My command does not seem to do the trick. Can you help me out?

  • ved-leachim's avatar
    ved-leachim
    Brass Contributor

    Teijo Hämäläinen 

     

    I would recommend using the AzureAD PowerShell Module. You can use the following command to get a list of all Cloud Only Accounts:

    Get-AzureADUser -All $true | Where-Object {$_.ImmutableId -eq $null}

     

    If you want a list with the Cloud Only Accounts without guests, you could use the following command:

    Get-AzureADUser -All $true | Where-Object {$_.ImmutableId -eq $null -and $_.UserPrincipalName -notlike "*#EXT#*"}

     

    • VasilMichev's avatar
      VasilMichev
      MVP

      There's also Get-MsolUser -Synchronized. Using the server-side filtering is faster approach, and also makes sure you don't get a trimmed list because of hitting the limit for number of objects returned (like when you have the Get-AzureADUser cmdlet above, without the -All switch, and filtering client-side).

Resources