r/M365Reports • • Jun 15 '22

Top 50 PowerShell Scripts for Microsoft 365 Admins

321 Upvotes

Most Microsoft 365 admins rely on PowerShell to manage their M365 organization. If you are one of them, this post is for you. I have listed 50+ most helpful PowerShell scripts to manage the M365 environment efficiently and securely.

https://o365reports.com/2022/06/15/top-50-powershell-scripts-for-microsoft-365-admins/

Most of the scripts listed here are scheduler-friendly. So, admins can easily automate the script execution.


r/M365Reports • • Oct 06 '21

Top 10 PowerShell Cmdlets for Monitoring Emails in Office 365

68 Upvotes

As an Office 365 admin, you need to monitor

  • Employee’s emails, 

  • Inbound/outbound mail traffic,

  • Number of spams and malware detected, 

  • Number of emails sent and received by a specific user,

  • Emails that matched with rules, policies, etc.

To ease your work, I have listed the top PowerShell cmdlets to monitor email activities . Along with the cmdlets, I have given 25+ PowerShell code samples to generate detailed email activity reports.

https://o365reports.com/2021/10/06/top-10-powershell-cmdlets-for-reporting-monitoring-emails-in-office-365/

I have listed few sample reports below:

  1. Email traffic report

  2. Inbound and Outbound email traffic report

  3. Mail flow status report

  4. Sent and received email count by users

  5. Office 365 spam reports

  6. Office 365 malware reports

  7. Identify which transport rule was applied on a mail

  8. Identify emails that were redirected to another email address

  9. Emails detected by DLP policy

  10. Top senders and recipient report

  11. Microsoft 365 message tracing report

If you have any other requirements or cmdlets, let me know. I will add them too.


r/M365Reports • • Apr 13 '22

It's Time to Migrate to Microsoft Graph PowerShell

56 Upvotes

Microsoft is deprecating the Azure AD PowerShell module and MS Online module in 2022. So, admins need to migrate to Microsoft Graph PowerShell SDK. If you fail to migrate your scripts to Microsoft Graph before that, you put their functionality and stability at risk.

I have written a blog which will guide you on the following things.

  • Download and install the Microsoft Graph PowerShell module

  • Connect to Microsoft Graph PowerShell

  • PowerShell script to automatically install and connect to MS Graph (Recommended)

  • Microsoft Graph PowerShell commands

  • Migrate scripts from Azure AD PowerShell to Microsoft Graph

  • Update and Uninstall Microsoft Graph SDK

https://m365scripts.com/microsoft365/connect-to-microsoft-graph-powershell/

Have you migrated to MS Graph PowerShell or still using Azure AD PowerShell modules?


r/M365Reports • • May 26 '22

Top 10 Microsoft Graph PowerShell cmdlets for Office 365 admins

53 Upvotes

It’s time to switch to MS Graph as the deprecation dates of Msol and Azure AD modules are approaching! As of now, we don't have any tools to convert Msol and Azure AD modules to their Microsoft Graph counterparts. Hence, I thought of creating a comprehensive guide to perform Office 365 reporting using MS Graph PowerShell. Check out the blog link below.

https://m365scripts.com/microsoft365/top-10-microsoft-graph-powershell-cmdlets-for-office-365-admins/

This blog lists MS Graph PowerShell cmdlets for the following Office 365 reports:

  • Get Microsoft 365 Users Reports

  • Generate Office 365 License Reports

  • Get Office 365 Groups Reports

  • Export Microsoft 365 Reports to a CSV

  • View Microsoft 365 reports in Grid View


r/M365Reports • • Sep 15 '21

[Script Sharing] PowerShell scripts for Office 365 administrators

53 Upvotes

Most admins prefer PowerShell over Admin centers. If you are one of them, you can utilize these PowerShell scripts for reporting and managing your Office 365 environment.

Script repository: https://o365reports.com/category/o365-powershell/

I hope this will help you.


r/M365Reports • • Oct 12 '22

Top 15 PowerShell scripts for O365 admins to audit Office 365 activities

52 Upvotes

Auditing plays a vital role in monitoring activities performed in the Microsoft 365 organization. Most admins prefer PowerShell over Audit log search. So, here is a list of 15 most useful PowerShell scripts to

  • Monitor user activities

  • Identify security threats

  • Audit mailbox activities

  • Track file sharing and accesses

  • Export email traffic report, etc

https://o365reports.com/2022/10/12/15-useful-powershell-scripts-to-audit-office-365-activities/

All the scripts listed here are scheduler-friendly. So, admins can easily automate the script execution.


r/M365Reports • • Sep 08 '22

[Script sharing] Manage Microsoft 365 licenses using MS Graph PowerShell

47 Upvotes

Due to Msol and Azure AD PowerShell module deprecation, administrators should switch to MSGraph PowerShell to manage Office 365. So, I have created an All-in-One PowerShell script to perform 10+ Office 365 license reporting and management activities using MS Graph PowerShell. By using the script, you can perform the following operations.

Office 365 License Reporting

  1. Get all licensed users report

  2. Get all unlicensed users report

  3. Get users with a specific license type

  4. Find all disabled users with licenses

  5. Office 365 license usage report

Office 365 License Management

  1. Bulk: Assign a license to users (input CSV)

  2. Bulk: Assign multiple licenses to users (input CSV)

  3. Remove license from a user

  4. Bulk: Remove all licenses from users (input CSV)

  5. Remove a specific license from all users

  6. Remove all licenses from disabled users.

  7. Set license usage location

https://o365reports.com/2022/09/08/manage-365-licenses-using-ms-graph-powershell

If you have any other requirements/use cases, or suggestions, let me know. I will include them in the next version.


r/M365Reports • • Aug 09 '22

Microsoft is retiring the 'Connect to Exchange Online with MFA' module: It's time to switch to a new module.

41 Upvotes

As per MC407050, Microsoft is going to retire the “Connect to Exchange Online PowerShell with MFA module” (i.e., EXO V1 module) on Dec 31, 2022. And the support ends on Aug 31, 2022. So, admins should move to EXO V2 module to connect to Exchange Online PowerShell with multi-factor authentication.

This blog will guide you on installing the EXO V2 module and use it with a MFA enabled accounts.

https://o365reports.com/2022/08/09/connect-to-exchange-online-powershell-with-mfa/

Advantages of Using EXO V2 Module: 

  • It uses modern authentication to connect to Exchange Online PowerShell.

  • A single cmdlet “Connect-ExchangeOnline” is used to connect to EXO with both MFA and non-MFA accounts.

  • It doesn’t require WinRM basic authentication to be enabled.

  • Helps to automate EXO PowerShell login with MFA. i.e., unattended scripts.

  • Contains REST API based cmdlets.

  • Provides exclusive cmdlets that are optimized for bulk data retrieval.


r/M365Reports • • Feb 10 '22

Protect Your Tenant! Monitor External Users' Activities to secure your M365 environment using PowerShell

36 Upvotes

Allowing external users to access the resources may lead to sensitive data leakage and security threats. So, admins must track the external user activities in the organization to identify suspicious incidents and make the required progress.

To track external user activities, I have written a PowerShell script. This script is helpful when you want to monitor and control external access and related activities.

https://o365reports.com/2022/02/10/audit-office-365-external-user-activities-using-powershell/

Additionally, the script supports in-built filtering params to generate more granular auditing reports. I have listed a few significant use cases below.

  1. Audit all the external users' activities

  2. Monitor external user activity for a custom period

  3. Track specific external user’s activities

  4. Schedule external user activity report

  5. Get monthly report on external users’ activities


r/M365Reports • • Jan 19 '22

Optimize Microsoft 365 license usage by finding and Removing unnecessary Licenses on Shared Mailboxes.

36 Upvotes

Generally, shared mailboxes do not require a license until their size exceeds 50 GB or litigation hold and in-place archive is not enabled. By finding and removing unnecessary licenses on shared mailboxes, admins can reduce the license cost or assign the license to the onboarding users.

Since the admin center has no direct way to find the licensed shared mailboxes, I considered writing a script to save admins' time. The script will provide a clear view of the following details.

  • Name

  • Shared mailbox size

  • Litigation hold status

  • In-place archive status

  • Assigned licenses

https://o365reports.com/2022/01/19/find-shared-mailboxes-with-license-using-powershell/


r/M365Reports • • Jul 27 '22

Get Microsoft E5 Subscription for Free with Microsoft Developer Program!

33 Upvotes

Microsoft launched its developer program for the benefit of admins. As an alternative to risking the production environment with new settings, and applications of new cmdlets, admins can test them in a test environment created through the Microsoft developer program. Now anyone can try out, build and test solutions in their own Office 365 developer accounts. 

Benefits that come up with Microsoft developer tenant:

  • Renewable Microsoft 365 E5 Subscription

  • Pre-loaded sample data sets

  • Customized experience 

  • Access to Experts

Looking for how to get it? Check out this blog - https://o365reports.com/2022/07/27/how-to-sign-up-for-microsoft-developer-program-for-free/


r/M365Reports • • Jul 20 '22

It's time to Block Basic Authentication in Microsoft 365

31 Upvotes

We all know that Microsoft is going to deprecate basic authentication in Exchange Online from Oct 2022. So, it is time to switch from basic auth to modern authentication to get an uninterrupted service.

This blog provides various ways (both UI and PowerShell) to disable basic authentication.
https://o365reports.com/2022/07/20/disable-basic-authentication-office-365/

As Password spray attacks are increasing nowadays, it’s better to disable basic authentication and switch to modern authentication instead of waiting for the end of support.


r/M365Reports • • Jun 09 '22

[Script sharing] Find all Office 365 Inbox rules that forwards emails to external users

31 Upvotes

Forwarding organization emails to external users are potentially dangerous and lead to sensitive data leakage. It is best to be aware of the Outlook rules configured for forwarding emails to external users.

To identify all the inbox rules with external forwarding configuration, I have written a PowerShell script. You can use the below link to download the script.

https://o365reports.com/2022/06/09/find-office365-inbox-rules-with-external-forwarding-powershell/

By referring to this report, you can block or remove external forwarding configuration.


r/M365Reports • • May 11 '22

[Script sharing] Audit Who Sent What Email from the O365 Shared Mailboxes

31 Upvotes

Finding out who sent what emails from the shared mailboxes are challenging task due to its following nature.

  1. Multiple users can send emails from shared mailboxes using 'SendAs' and 'SendOnBehalf' permission.

  2. Emails sent from shared mailboxes are not stored in the shared mailbox' sent items folder. By default, it will be saved in the senders' mailbox.

If you use audit log search, you can't filter out shared mailboxes alone. So, I have written a PowerShell script to audit who sent emails from the shared mailboxes.

https://o365reports.com/2022/05/11/find-who-sent-email-from-shared-mailbox-in-office-365-using-powershell

With this script, you can generate 5 granular reports.

  • Track all the emails sent from shared mailboxes

  • Detect who sent emails from a specific shared mailbox

  • Generate a report for custom period

  • Find emails sent using 'SendAs' delegation

  • Track emails sent using 'SendOnBehalf' permission

  • Automate report generation to run the script periodically


r/M365Reports • • Jan 25 '22

Microsoft Teams: Everything you need to know about archiving teams

30 Upvotes

In Microsoft Teams, teams are created for various purposes. Over time, created teams might fall out of use. For example,

  • In an organization, when a project ends.

  • In education centers, when an academic year ends.

When teams are no longer active, you can archive them to keep files and govern information. I have written a blog to know everything about archiving teams in MS Teams. The blog gives detail in the following categories.

  1. Need of archiving in teams

  2. Who can archive teams

  3. Enable archive through GUI

  4. Bulk archive team using PowerShell

  5. Find all the archived teams in the organization

  6. How to unarchive teams

https://m365scripts.com/microsoft-teams/how-to-archive-team-in-microsoft-teams/


r/M365Reports • • Sep 15 '22

Microsoft Teams will soon provide search results that include the entire chat thread

29 Upvotes

MS Teams New Update!

Microsoft has enhanced MS Teams search functionality to allow users to view the entire chat thread. The rollout is expected to begin in October 2022. It is currently available in Public preview for Teams desktop and web apps. Refer here for more detailed info.

https://m365scripts.com/microsoft-teams/turn-on-this-setting-to-view-full-chat-thread-via-teams-search/


r/M365Reports • • Nov 23 '21

All-in-One PowerShell Script to Perform Office 365 License Management and Reporting in a Jiffy

29 Upvotes

I have created a PowerShell script to perform more than 10 Office 365 license reporting and management activities. By using the script, you can perform the following operations.

Office 365 License Reporting

  • Get all licensed users report

  • Get all unlicensed users report

  • Get users with specific license type

  • Find all disabled users with licenses

  • Office 365 license usage report

Office 365 License Management

  • Bulk: Assign a license to users (input CSV)

  • Bulk: Assign multiple licenses to users (input CSV)

  • Remove license from a user

  • Bulk: Remove all license from users (input CSV)

  • Remove specific license from all users

  • Remove all licenses from disabled users.

  • Set license usage location

https://o365reports.com/office-365-license-reporting-and-management-using-powershell

If you have any other requirements/use-cases or suggestions, let me know. I will include them in the next version.


r/M365Reports • • Jan 05 '23

2022 Recap: Essential Office 365 Scripts for Administrators

28 Upvotes

"Hello, fellow admins! Are you looking to boost your productivity with PowerShell scripts? From automating tasks to managing your environment, this 2022 Recap covers everything from the most significant PowerShell scripts to the immediate feature updates, making your life as an admin, a breeze.
Don't wait any longer! Check out the following blog now and let us know which script you find the most useful!
https://m365scripts.com/microsoft365/microsoft-365-scripts-2022-wrap-up/

Our best wishes for a wonderful business year to you!


r/M365Reports • • Nov 01 '22

Manage Multi-Factor Authentication Strengths in Microsoft 365

28 Upvotes

In recent months, major corporations like Uber, Microsoft, and Cisco have been victimized by MFA fatigue attacks. All these attacks involved social engineering and theft of employee credentials to gain access to privileged user accounts. To tackle such threats, Microsoft came up with advanced MFA settings in Azure.

When Microsoft is making such big efforts, it is also important for admins to ensure that all users comply with MFA standards in the organization. Wondering how to check?

Check out the advanced MFA settings and where you can find MFA registered users here.

https://o365reports.com/2022/11/01/manage-multi-factor-authentication-strengths-in-microsoft-365/


r/M365Reports • • Mar 11 '25

Who's Deleting Emails from Your Shared Mailboxes?

26 Upvotes

Ever found important emails missing from a shared mailbox, leaving your team puzzled? Without proper tracking, these situations create accountability nightmares and make it harder to detect external breaches. 

No worries! Use this PowerShell script to gain complete visibility into shared mailbox email deletion activities, including details on who deleted emails and when. 

https://o365reports.com/2025/03/11/audit-email-deletions-in-microsoft-365-shared-mailboxes-powershell/ 

Take control of your shared mailbox email management with this script that helps you: 

  • Identify exactly who deleted emails 

  • Audit organization-wide or targets specific shared mailboxes 

  • Filter by subject line to track missing messages 

  • Focus on specific user’s deletion activities 

Discover how this script monitors shared mailbox email deletion audits and helps you enhance security in your Microsoft 365 environment. 


r/M365Reports • • Jun 03 '23

Automate Microsoft 365 User Onboarding Using Power Automate

25 Upvotes

Are you tired of spending hours processing the onboarding tasks in your Microsoft 365 organization? 😩 With Microsoft Power Automate, you can easily automate the user creation process and manager assignment with approval for each user. This can really help in the scenario where a new employee joins a company and needs access to various company systems and resources that are managed through Azure Active Directory.

In the traditional manual process, an IT administrator would have to create a new user account in Azure AD and assign the manager. Tackling this process manually can be time-consuming, error-prone, and require multiple approvals. So, look into our latest blog for hassle free user onboarding process using Power Automate.

https://m365scripts.com/microsoft365/automate-microsoft-365-user-onboarding-using-power-automate/


r/M365Reports • • Oct 17 '22

Use SQL to instantly query Microsoft 365 resources (open source, no DB required)

25 Upvotes

Steampipe is an open source project to query cloud APIs (Azure, GitHub, Slack, etc) with SQL. The Microsoft 365 plugin was just released! The source is on GitHub and the docs are on the Steampipe Hub. Here's an example based on a table "Calendar Event":

SELECT subject, online_meeting_url, start_time FROM microsoft365_calendar_event;

+----------------+-------------------------------------+---------------------------+
| subject        | online_meeting_url                  | start_time                |
+----------------+-------------------------------------+---------------------------+
| Weekly Meeting | https://meet.google.com/xxx-yyyy-zz | 2022-08-03T08:00:00+05:30 |
+----------------+-------------------------------------+---------------------------+

Let me know if this is useful. We're always open to suggestions and feedback!


r/M365Reports • • Mar 08 '22

Tracing Emails in Microsoft 365 with PowerShell

25 Upvotes

Message tracing helps admins to monitor mail flow and delivery status. With message trace, admins can  

  • Analyze what happened to an email like whether it was received, rejected, deferred, or delivered at the other end.

  • Troubleshoot email delivery problems. 

  • Validate email policies and mail flow rules.

I have written a blog on message tracing, along with the cmdlet examples to solve the most needed use cases.

https://m365scripts.com/exchange-online/how-to-track-emails-with-office-365-message-trace-using-powershell/

I have listed a few use cases below,

  • Get message trace details for custom range.

  • View specific properties of message tracing

  • Get message trace by email subject

  • Export message trace report to CSV file

  • View message trace report in Grid view

  • Get message trace details

  • Extended message trace using PowerShell

  • Get message trace for older than 90 days


r/M365Reports • • May 30 '25

Are you truly in control of your Entra ID applications?

23 Upvotes

You probably have dozens (or hundreds) of app registrations in your Entra ID tenant right now. However, most of these apps can be assigned with permissions they don't need or were created for testing and never cleaned up. 

The real concern? These Entra apps are often hold high-privilege access but receive far less monitoring than user accounts, making them an easy target for attackers. 

To help you get ahead of potential risks, we’ve built a PowerShell script that simplifies auditing Entra ID application operations. 

Whether you're investigating a security incident or just doing regular access reviews, this script helps you: 

  • Track app registration, deletion, or modifications 

  • Identify who granted app consent and when 

  • Monitor service principal updates and credential changes 

  • Filter by actor, app, operation type, or time period 

Download the script and audit app operation activities before they become a security gap! 

https://o365reports.com/2025/05/27/monitor-entra-app-operations-using-powershell/