Apr 29 2019
04:37 AM
- last edited on
Jan 14 2022
04:39 PM
by
TechCommunityAP
Apr 29 2019
04:37 AM
- last edited on
Jan 14 2022
04:39 PM
by
TechCommunityAP
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?
Apr 29 2019 05:32 AM
Solution@Teijo Hämäläinen I would try following Get-MsolUser -All | ?{-not $_.lastdirsynctime}
Apr 29 2019 09:46 AM
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).
Apr 30 2019 12:09 AM
thanks, definitely a better solution.
Martin
May 04 2019 12:34 PM
@Martin RublikThere is another easier option to use it. Cloud only and on prem users have big difference - Its called Immutable ID
So Get-MsolUser | where-Object {$_.ImmutableId -eq $null} -> for On prem users
Get-MsolUser | where-Object {$_.ImmutableId -ne $null} for Azure AD users ( Cloud users)
May 07 2019 11:20 PM - edited May 07 2019 11:38 PM
Apr 22 2020 05:02 AM
I think should be other way around 🙂
Get-MsolUser | where-Object {$_.ImmutableId -eq $null} -> for Azure AD cloud users;
Get-MsolUser | where-Object {$_.ImmutableId -ne $null} -> for On premise users;
Oct 12 2020 04:15 AM
@Scorpio69 Definitively need -All switch to get all users.
Get-MsolUser -All | where-Object {$_.ImmutableId -eq $null}
Apr 05 2022 02:41 AM
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#*"}
Oct 09 2023 10:48 AM
Apr 29 2019 05:32 AM
Solution@Teijo Hämäläinen I would try following Get-MsolUser -All | ?{-not $_.lastdirsynctime}