Forum Discussion
escupham
Oct 31, 2017Steel Contributor
Get a report of all cloud accounts
I need to get a list of all cloud only accounts (onmicrosoft.com). I can see in Azure AD User Reports the Source field will help narrow this down for me as we sync our on-prem AD to the cloud, so those have a Source of 'Windows Server AD' and the cloud accounts have a Source of 'Azure Active Directory'. However it doesn't appear you can do any filtering within the user report. Is there a PowerShell command I could run that would give me a list of all users with a source of Azure Active Directory?
- Paul CunninghamSteel Contributor
If you're using the newer AzureAD module:
Get-AzureADUser | Where {$_.DirSyncEnabled -ne $true}
Interestingly, the values appear to be either "True" or "null", not "False.
PS C:\> Get-AzureADUser | Group-Object -Property:DirSyncEnabled Count Name Group ----- ---- ----- 98 True {class User {... 2 {class User {...
- David BlodgettCopper Contributor
The trouble I'm having with this command is that it does not return all objects. While the documentation states that there is an -All flag that should achieve this,(https://docs.microsoft.com/en-us/powershell/module/azuread/get-azureaduser?view=azureadps-2.0) it does not appear to work.
Running Get-Help Get-AzureADUser does not show the -All flag.
PS C:\Windows\system32> Get-Help Get-AzureADUser
NAME
Get-AzureADUser
SYNOPSIS
Retrieves a specific user from Azure Active Directory
SYNTAX
Get-AzureADUser [-Top <Nullable`1[Int32]>] [-Filter <String>] [<CommonParameters>]
Get-AzureADUser [-SearchString <String>] [<CommonParameters>]
Get-AzureADUser -ObjectId <String> [<CommonParameters>]
DESCRIPTION
RELATED LINKS
REMARKS
To see the examples, type: "get-help Get-AzureADUser -examples".
For more information, type: "get-help Get-AzureADUser -detailed".
For technical information, type: "get-help Get-AzureADUser -full".
For online help, type: "get-help Get-AzureADUser -online""All" is a Boolean parameter, so you have to use it like this:
Get-AzureADUser -All $true
I know, stupid, just add it to the list of inconveniences for the module...
You can use something like this:
Get-MsolUser | ? {-not $_.LastDirSyncTime}
- Jai VermaBrass Contributor
VasilMichev This is not just enough, as it also list Guest users. Also add filter to exclude guest so that you only gets enterprise cloud only users.