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
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.
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 email@example.com | FL
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.
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!
For paperback version click here
For Kindle version click here