Retrieve Users, Including Names and Country, from Office 365

Jasper Oosterveld

by Jasper Oosterveld on 11/24/2015

Share this:
Print

Article Details

Date Revised:
11/24/2015

Applies to:
Azure Active Directory Module for Windows PowerShell, Microsoft Online Services Sign-In Assistant for IT Professionals, Office 365, PowerShell


Recently for a client, I had to retrieve all the Office 365 users, including name and country, for one of our customers. I used PowerShell for this. Let’s take a look at my steps.

I installed the necessary tools: https://msdn.microsoft.com/en-us/library/azure/jj151815.aspx

First install the Microsoft Online Services Sign-In Assistant for IT Professionals RTW from the Microsoft Download Center. Then install the Azure Active Directory Module for Windows PowerShell (64-bit version), and click Run to run the installer package.

After that, I executed the following cmdlets:

$credential = get-credential

Connect-MsolService -Credential $credential

Get-MsolUser | Select-Object DisplayName, Country | Export-Csv C:\users.csv

You are now able to open the CSV in Excel and have you results ready. Nice :-). I am a PowerShell n00b but this was easy to do for me :-).

Note: You do need to be an Office 365 Global Administrator to connect through PowerShell.

You can find Jasper’s original post here: http://www.jasperoosterveld.com/2015/11/retrieve-users-including-names-and-country-from-office-365/


Topic: PowerShell

Sign in with

Or register