Office 365

Retrieve users including names and country from Office 365

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

First 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 pretty easy to do for me 🙂

ps.

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

You Might Also Like

No Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.