Manage Microsoft 365 Users, Licenses, And Groups with PowerShell 

With Microsoft 365 admin center, you can easily manage Microsoft 365 user accounts and licenses. But when it comes to reporting, the admin center gives limited data with fewer customization options. So, it’s necessary to make use of Office 365 PowerShell for more customization and speedy data retrieval. 

This blog lists the top 15 Office 365 PowerShell cmdlets for admins to manage their Azure AD users, groups, and licenses. To retrieve data from Office 365, first, you need to connect to Office 365 PowerShell. 

 

Connect to Office 365 PowerShell: 

To connect Office 365, run the below cmdlet. 

You can use the above cmdlet for both MFA and non-MFA admin accounts. 

Note: In order to use the ‘Connect-MsolService’ cmdlet, you need to install MsOnline Module. Else, you can use the PowerShell script to connect Office 365 services. 

After connecting to Office 365 PowerShell, you can run the following cmdlets to get the desired report. 

 

Get Microsoft 365 Users Report: 

To view all the user accounts, you can execute the following cmdlet. 

The output looks similar to the below screenshot. 

Get all Office 365 users

 

By default, the Get-MsolUser cmdlet only displays UPN, display name, and license status. To view users with additional properties, you can use the Select cmdlet with the required attributes. Here’s an example command that displays the Display Name, Department, License Status, and Usage Location for every user account. 

The above cmdlet produces the following result: 

Export office 365 users

 

To get enabled user accounts, 

 

To view admin roles assigned to a user, 

The above cmdlet lists the admin roles assigned to John. 

 

Generate Office 365 License Reports: 

To get all the licensed users, 

The above cmdlet produces output similar to the screenshot below: 

Office 365 licensed users report

If you want to generate detailed Office 365 license report, you can refer our earlier blog post to list users and their assigned licenses. 

 

To view unlicensed users, 

 

To identify users with specific licensing plan, 

The above cmdlet helps to list users with E3 license plan. 

 

To get a list of Microsoft 365 licenses available in the tenant and their status, 

Also, the above cmdlet shows NextLifeCycleDate which helps to identify license’s expiry date, disabling date and deletion date based on its current status. 

Office 365 license usage report

You can also use our pre-built script to generate Office 365 license expiry date report. 

 

To identify license usage (i.e., active units and consumed units) information, 

Get Office 365 license report

 

Generate Office 365 Group Reports: 

To view all the groups available in the organization, run the below cmdlet 

Export office 365 groups

You can also refer to our script to list Office 365 groups and export them to CSV. 

 

To list all the distribution groups in the tenant, 

To get distribution group and their members details, you can refer to our earlier blog post. 

 

To view all the security groups in the organization, 

 

To retrieve member(s) of a specific group, 

The above cmdlet produces result as follows:

Office 365 group members report

Note: The MsolGroup cmdlets don’t include Dynamic Distribution Groups. To generate report on DDL groups, you can refer to our dedicated script to list Dynamic Distribution Group members. 

 

Export Microsoft 365 Report to CSV: 

To export the Microsoft 365 report result to CSV, you need to combine the above-mentioned cmdlets with Export-CSV cmdlet. 

For example, to export all the office 365 users with specific parameters, 

The exported CSV file looks similar to the screenshot below: 

Export Office 365 users to CSV

 

View Report in Grid View: 

The Out-GridView cmdlet sends output to an interactive table in a separate window where you can customize column, sort rows, filter, copy and paste data. 

To view Office 365 user report in the grid view, 

Export office 365 reports

 

 

Challenges in Generating Reports using PowerShell:

One of the biggest problems with PowerShell is, you need to use different cmdlets to generate each report. If you are new to PowerShell, it’s really hard to identify the right cmdlet to prepare the required Microsoft 365 report.  

Here comes AdminDroid, Microsoft 365 reporting and auditing tool. AdminDroid provides 100+ reports and handful of dashboards as free to manage your organization’s users, licenses, subscription, license changes, groups, group membership, membership changes, user logins, password changes, etc. 

Office 365 reporting tool by AdminDroidMicrosoft 365 Reporting Tool AdminDroid

Additionally, AdminDroid offers 950+ pre-built reports on various Office 365 services like Azure AD, Exchange Online, SharePoint Online, Microsoft Teams, One Drive, etc. For your Office 365 reporting and auditing needs, you can try Microsoft 365 reporting tool by AdminDroid and see how it works for you. 

 

I hope this blog will help you in managing Office 365 users, licenses, and groups. If you have any queries, you can ask them in the comments section.