lunes, 29 de febrero de 2016

Get Office 365 users using Powershell

Sometimes, at work I need to check the licensed users in Office 365, I can check them from the Office 365 Admin website, but I’m not sure if I’m able to export them to an Excel (Or CSV file).

So, in order to do that I’ll do it using our little friend, the uncle PowerShell.

Before jumping into the commands, you will need to install some modules to connect to your Azure Office 365 platform.

  1. First install the  Microsoft Online Services Sign-In Assistant for IT Professionals RTW
  2. Then Azure Active Directory Module for Windows PowerShell (64-bit version) 
Now, open a powershell terminal and type:
 
PS C:\WINDOWS\system32> Connect-MsolService
A new window will pop up, enter your Office 365 credentials there. And then, if you don't have any error, you will be in. Now type the following command:
PS C:\WINDOWS\system32> Get-MsolUser | Where-Object {$_.isLicensed -eq "TRUE"} | Export-Csv C:\LicensedUsersOffice365.csv


And that is it, you will have an excel file of all your licensed users on Office 365.