Time needed: 2 minutes.
Getting a list of all Office 365 Global administrators with Powershell is easy. Here is how to do it with a simple one liner.
- Open a Powershell session and connect to Office 365
At a PowerShell Prompt connect to Office 365 with the command:
- Authenticate with Office 365
Sign in to Office 365 when prompted with a Global Administrator account.
- List Global Admins with the Get-MsolRoleMember cmdlet
Use the following command to list all global admins:
Get-MsolRoleMember -RoleObjectId $(Get-MsolRole -RoleName "Company Administrator").ObjectId
If Connect-MsolService does not work for you, then you need to follow these instructions to install the Azure Active Directory Module.
If you’d like to export the list of Global Administrators to a CSV file instead, use a PowerShell command like the following:
Get-MsolRoleMember -RoleObjectId $(Get-MsolRole -RoleName "Company Administrator").ObjectId | Select-Object -Property DisplayName,EmailAddress | Export-Csv -NoTypeInformation -Path D:\GlobalAdmins.txt