How do I export users from Office 365, using PowerShell?
Important: The steps in this article require that you connect to Office 365 with Windows PowerShell. Refer to the Connect to Office 365 PowerShell article from Microsoft for detailed steps on how to connect to Office 365 using Windows PowerShell.
Quite often, it is necessary to have an overview of all the licensed users within an Office 365 tenant. Using PowerShell and the Office 365 cmdlets, it is possible to get a list of users, both with and without licenses, for further analysis (for example, for reporting purposes).
The following PowerShell cmdlet will provide this output:
Get-MsolUser | Get-Member | Out-GridView
This Microsoft Support article provides a full explanation of how to do this: https://support.microsoft.com/en-us/kb/2777380.