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:
- 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
- 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.