1. Windows Management Framework
2. Windows PowerShell 3.0
3. The Microsoft Online Services Sign-In Assistant
4. Windows Azure AD Module
Then run Windows Azure Active Directory Module for Windows PowerShell. Connect to Office 365 with cmdlet Connect-MsolService and enter the corresponding administrator credentials.
After that request active users with cmdlet:
PS C:\Windows\system32> Get-MsolUser | Where-Object { $_.isLicensed -eq "TRUE" } | Select-Object UserPrincipalName, DisplayName, Country, City, Department,
UsageLocation | Out-GridView
Source: Microsoft Support