Export Active AD users

Daniel Brooks 5 Reputation points
2023-03-30T17:49:16.3866667+00:00

Hello.

I need to export a list of active AD users in Azure and include users who are showing Cloud Only in our 365 environment.

At one point users were added on Prem in AD but others were added in 365 so we have Hybrid users and Cloud only users.

I am looking for a quick easy way to accomplish this most likely using powershell.

Any suggestions would be greatly appreciated.

Thank you.

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
21,699 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Syed Shiraz Shahid 280 Reputation points
    2023-03-30T19:15:22.7233333+00:00

    To export a list of active AD users in Azure, including users who are showing Cloud Only in your 365 environment, you can use the Azure Active Directory PowerShell module. Here are the steps to do so:

    1. Install the Azure Active Directory PowerShell module: You can download and install the module from the PowerShell Gallery using the following command: Install-Module AzureAD
    2. Connect to your Azure AD tenant: Use the following command to connect to your Azure AD tenant:
        Connect-AzureAD
            
        
    1. Export the list of active AD users: Use the following command to export a list of active AD users to a CSV file:
        
    
        
        Get-AzureADUser | Where-Object {$_.AccountEnabled -eq $true} | Select-Object DisplayName, UserPrincipalName, UsageLocation, UserType, ImmutableId | Export-CSV -Path C:\Path\To\Export\File.csv -NoTypeInformation
            
        
    1. Include Cloud Only users in the export: To include Cloud Only users in the export, you can add the **`-All $true`** parameter to the **`Get-AzureADUser`** command. This will return all users in the Azure AD tenant, including those that are Cloud Only. The updated command would be:
        
        
        
    
        Get-AzureADUser -All $true | Where-Object {$_.AccountEnabled -eq $true} | Select-Object DisplayName, UserPrincipalName, UsageLocation, UserType, ImmutableId | Export-CSV -Path C:\Path\To\Export\File.csv -NoTypeInformation
            
        
    This command will export a list of active AD users in Azure, including Cloud Only users, to a CSV file located at the specified path. The file will contain the users' display names, user principal names, usage locations, user types, and immutable IDs.
    
    
    0 comments No comments

  2. Givary-MSFT 32,581 Reputation points Microsoft Employee
    2023-03-31T07:16:39.47+00:00

    @Daniel Brooks Adding to the above, similar requirement has been discussed here - https://techcommunity.microsoft.com/t5/microsoft-entra-azure-ad/how-to-list-users-synced-from-onprem-ad-and-cloud-only-users/m-p/498883 and tested the commands in my tenant and works as expected.

    Let me know if you have any further questions, feel free to post back.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.