Top 50 PowerShell Scripts for Microsoft 365 Admins
If you have already landed on o365 reports.com, you would know that it has contributed plenty of scripts for various requirements of Microsoft 365 admins. This blog will list the 50+ Microsoft 365 PowerShell scripts that are useful to manage and secure M365 environment efficiently.
We have categorized the scripts as given below.
- Office 365 license management
- Office 365 user management
- Guest and external user management
- Group and group membership management
- Exchange mailbox management
- Exchange Online email auditing
- Microsoft Teams & SharePoint Online management
- General Office 365 scripts
Note: Most scripts listed here are scheduler friendly. You can schedule them in Windows Task scheduler to run the script as a scheduled task.
Office 365 License Management:
Office 365 licenses are required to access Office 365 services. So, it’s necessary to identify licensed users, license usage, and license expiry date to manage the license efficiently and regain unused license to reduce license cost.
- Office 365 license report – Exports all the licensed users with their assigned licenses and service status.
- License expiry date report– Provides all Office 365 subscription plans available in the organization and their details such as expiry date, subscription renewal date, etc.
- License management and reporting script– Allows admins to perform 10+ license management and reporting actions, including license assignment and removal.
- Find licensed shared mailbox report- Helps to identify shared mailboxes with licenses.
Office 365 User Management:
People in the organization require a user account to access Office 365 services. To identify user activities, inactive users, password status, etc., admins can use the PowerShell scripts given below.
- Users’ last logon time report– Lists all users and their last login time to identify inactive users.
- MFA status report– Helps to identify Office 365 users’ MFA status and export the report to CSV file.
- Real last logon time report– Exports M365 users’ last activity time to identify inactive users accurately in the organization.
- Password report– Lists all users and their last password change time, password expiry date, etc.
- Admin report– Exports detailed report on Office 365 admins and their roles.
- Manager report– Gets Office 365 users and their manager details and helps to identify users without a manager.
- User logon history– Helps to track Office 365 users’ login activities and identify suspicious behavior.
- User activity report– Tracks specific user or admin’s activity to identify malicious activities.
Guest and External Users Management:
Guests and external users can access the organization’s resources based on the settings and permission grants. So, admins need to track guests and external users & their activities to protect sensitive data.
- Get SPO external users– Lists all external users in SharePoint Online.
- Guest user report– Exports Office 365 guest users with their group memberships.
- Audit external user file access– Tracks external users’ file accesses in SharePoint Online and OneDrive for Business.
- Audit SPO external sharing– Audits SharePoint Online resources shared with external users.
- Audit external user activity– Helps to track external users’ activities in your M365 environment.
Office 365 Group and Group Membership Management:
Different kinds of groups are available in Office 365 for various purposes. Admin can create respective groups based on their need and project nature. Admins can download the PowerShell scripts below to get all groups and their membership details.
- Office 365 distribution group report – Lists all distribution groups and their membership details.
- DDL members report– Shows all the Dynamic Distribution groups and their member details.
- Office 365 group and members report – Exports Microsoft 365 groups and membership report to CSV file.
- User membership report– Lists all Office 365 groups a user is member of.
- Show all DLs a user is member of – Helps to get all distribution groups a user is a member of.
- Office 365 group storage report – Retrieves storage used by Office 365 groups and exports them to CSV file.
- Nested distribution group membership – Exports nested distribution list members using PowerShell
Exchange Mailbox Management:
This category contains PowerShell scripts related to Exchange Online mailboxes and their configurations, such as delegation permission, archive status, email forwarding configs, hold status, etc.
- Mailbox permission report– Lists all mailboxes and their delegates who have ‘full access, send as, and send on behalf’ permissions.
- Shared mailbox permission report– Shows all the shared mailboxes and their members and delegates.
- List all mailboxes a user has access – List all mailboxes a user has access to. The report includes full access, send as, and send on behalf permissions.
- Non-owner mailbox access report – Helps to detect who accessed another user’s mailbox and when.
- Mailbox size report – Shows all the mailboxes and their storage size.
- Archive mailbox size report – Helps to find archive mailboxes and online archive size.
- Email forwarding configuration report – Lists mailboxes with auto email forwarding configuration to other mailboxes.
- Inbox rules with external forwarding configuration – Finds inbox rules of all mailboxes that forward emails to external users.
- Mailbox hold report – Exports mailboxes and their hold status, such as litigation hold, in-place hold, retention hold, etc.
- Auto-reply configuration report – Helps to identify users with Out of Office (OOF) and their status, scheduled period, etc.
- Calendar permission report – Exports 6 different Office 365 calendar permission reports to CSV.
Email Audit Reports:
These PowerShell scripts help admins track email activities, such as email traffic, spam & malware emails, email deletions, emails sent by delegates, etc.
- Mail traffic report – Exports sent and received email count by users in your Exchange Online environment.
- Spam and malware report – Provides sent and received spam and malware email details
- Audit email deletion – Helps to find when and who deleted what email from their own mailbox or delegated mailbox.
- Audit emails sent using SendAs permission – Tracks emails sent using ‘SendAs’ permission from delegated mailbox.
- Find who sent emails from shared mailbox – Audits who sent what email from the shared mailbox in Microsoft 365 organization.
SharePoint Online & Microsoft Teams Management:
Microsoft Teams statistics and usage reports can be generated using the below scripts. Also, a few SharePoint Online audit scripts to track anonymous links and file deletions are available in this category.
- Teams reports – Generate 10+ Microsoft Teams reports, including all teams, all channels, team members, channel members & owners, private channels report, etc.
- Find orphaned teams – Helps to identify teams without owners.
- Audit Microsoft Teams meetings – Exports all Teams meetings and their participants list to CSV file
- Audit Anonymous link creation and access report – Audits anonymous link creation, modification, removal, and access in SharePoint Online and OneDrive.
- Audit file deletions – Helps to track when and who deleted what file in SharePoint Online & OneDrive.
General Microsoft 365 PowerShell Scripts:
General and Office 365 service connectivity scripts are available in this category.
- Office 365 email addresses report – Exports all Office 365 email addresses and their alias to CSV file.
- Connect to Exchange Online PowerShell – Helps to Install Exchange Online PowerShell module and connects to EXO.
- Connect to all Office 365 services – Helps to connect to multiple Office 365 services such as Azure AD, Exchange Online, SharePoint Online, Microsoft Teams, and Security & Compliance center.
- Connect to Microsoft graph – Installs Microsoft Graph PowerShell module and connects to Microsoft 365.
- Add external email warning message – Helps to add external email warning messages for emails received from external users.
- Enable mailbox auditing – Enables mailbox auditing for all mailboxes to track certain or all actions performed by mailbox owner, delegates, and admins.
Get Microsoft 365 Reports in a Few Mouse Clicks:
PowerShell got you confused? tired of manually executing PowerShell scripts? Look no further, try AdminDroid Microsoft 365 reporting tool and see how it helps you in managing your Microsoft 365 environment.
AdminDroid provides 1500+ pre-built reports and 20 smart visually appealing dashboards to know about your Office 365 environment at a glance. This tool provides reports on Office 365 reporting, auditing, analytics, usage statistics, security & compliance, etc.
Each report provides AI-powered graphical analysis to gain insights and better understand the data in a visually appealing manner.
Additionally, AdminDroid offers 100+ reports and dashboards completely for free. It includes reports on Users, Licenses, Groups, Group Members, Devices, Login Activities, Password Changes, License Changes, and more. The free edition doesn’t have any restrictions in reporting functionalities such as customization, scheduling, and exporting. Download Free Office 365 reporting tool by AdminDroid and see how it helps for you.
I hope this blog will be helpful in generating Microsoft 365 reports.