Office 365 powerhell Archives - Office 365 Reports Generate Office 365 reports with PowerShell and stay informed about M365 news, tips, how-to's, and security best practices for efficient Microsoft 365 management. Fri, 22 Mar 2024 13:17:47 +0000 en-US hourly 1 /wp-content/uploads/2024/01/cropped-favicon-32x32.png?v=1705577855 Office 365 powerhell Archives - Office 365 Reports 32 32 Manage Microsoft 365 Users, Licenses, And Groups with PowerShell  https://o365reports.com/2021/04/21/manage-microsoft-365-users-licenses-and-groups-with-powershell/?utm_source=rss&utm_medium=rss&utm_campaign=manage-microsoft-365-users-licenses-and-groups-with-powershell https://o365reports.com/2021/04/21/manage-microsoft-365-users-licenses-and-groups-with-powershell/#respond Wed, 21 Apr 2021 10:33:47 +0000 http://o365reports.com/?p=2874 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…

The post Manage Microsoft 365 Users, Licenses, And Groups with PowerShell  appeared first on Office 365 Reports.

]]>
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. 

Connect-MsolService

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. 

Get-MsolUser –All

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. 

Get-MsolUser -All| Select DisplayName,Department,IsLicensed,UsageLocation

The above cmdlet produces the following result: 

Export office 365 users

 

To get enabled user accounts, 

Get-MsolUser -EnabledFilter EnabledOnly -All

 

To view admin roles assigned to a user, 

Get-MsolUserRole –UserPrincipalName John@contoso.com

The above cmdlet lists the admin roles assigned to John. 

 

Generate Office 365 License Reports: 

To get all the licensed users, 

Get-MsolUser -All | Where-Object {$_.IsLicensed -eq $true} | ft

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, 

Get-MsolUser –UnlicensedUsersOnly -All

 

To identify users with specific licensing plan, 

Get-MsolUser -All | Where-Object {($_.licenses).AccountSkuId -equal "ENTERPRISEPACK"} | ft

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, 

Get-MsolSubscription

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-MsolAccountSku

Get Office 365 license report

 

Generate Office 365 Group Reports: 

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

Get-MsolGroup –All

Export office 365 groups

You can also refer to our script to list Office 365 groups and export them to CSV. In case you want to manage ownership for these groups, you can also achieve it using PowerShell.

 

To list all the distribution groups in the tenant, 

Get-MsolGroup -All -GroupType DistributionList

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, 

Get-MsolGroup -All -GroupType Security

 

To retrieve member(s) of a specific group, 

Get-MsolGroupMember –GroupObjectID <ObjID> -All

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, 

Get-MsolUser -All | Select DisplayName,Department,IsLicensed| Export-CSV -Path <File Path> -NoTypeInformation

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, 

Get-MsolUser –All | Out-GridView

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 1500+ 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. 

The post Manage Microsoft 365 Users, Licenses, And Groups with PowerShell  appeared first on Office 365 Reports.

]]>
https://o365reports.com/2021/04/21/manage-microsoft-365-users-licenses-and-groups-with-powershell/feed/ 0