How to List Users in Office 365 Using PowerShell

If you don’t know how to connect PowerShell to Office 365 then read this post first to get started: How to Connect PowerShell to Office 365

List Users

The easiest way to return a list of all users is to run the Get-MsolUser cmdlet. By default, it will return only the UPN, Display name and the isLicensed attributes.
Get-MsolUser
Office 365 PowerShell List User Accounts

User Attributes

Each user contains a number of attributes defining their settings and personal information such as phone number Department name, the date they last changed their password. You can export some great information into a CSV file and produce some reports in Excel really easily. Maybe as part of a security audit you could export a list of all users who have their password set to never expires?
To return all available attributes of a user account you can run the Get-MsolUser cmdlet, specify the UPN of the user account and pipe the output as a formatted list.
Get-MsolUser –UserPrincipalName ian.waters@office365lab.co.uk | FL
Office 365 PowerShell User Attributes

 

Summary

Listing user accounts in Office 365 using PowerShell is easy and exposes some very useful user attributes. You can create very useful scripts using these two cmdlets and even build reports to better manage your 365 tenant.

Subscribe to the blog if you want to see my future tips, each week we I’ll post useful commands and scripts for you to learn from and experiment with.



Get this blog post sent to you as a PDF file to read later

Enter your email address and press Send Now


If you want to learn more you can buy my book from Amazon, either the paper back or kindle version. My advice is to buy the paperback version so you can keep it on your desk for easy reference!

Office 365 PowerShell Book

For paperback version click here

For Kindle version click here

 

 

 

Author: Ian@SlashAdmin

Share This Post On

Submit a Comment

Your email address will not be published. Required fields are marked *

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