Microsoft 365 PowerShell Scripts
A collection of PowerShell scripts and tools, in varying stages of completion, for managing, auditing, and reporting on Microsoft 365 tenants. The collection spans Entra ID (Azure AD), Exchange Online, SharePoint/OneDrive, Teams, Intune, Microsoft Defender, Purview/compliance, and the Power Platform.
This collection is in active development, and the scripts are at different stages of completion. Some are functional reporting tools that query live Microsoft 365 data; some are partially implemented (they retrieve real data for parts of the report and use sample values for others); and some are placeholders whose reporting logic is scaffolded but not yet connected to live data (they currently emit sample output). The Status column in the Script Index shows where each script stands.
Scripts are provided as-is. Review and test each one before running in production.
Table of Contents
Overview
This repository provides 76 reporting and auditing scripts (numbered 00-75) for Microsoft 365 administrators, in varying stages of completion. Completed scripts typically read tenant configuration or activity data and export a CSV report, making them suitable for scheduled reporting, security reviews, and compliance audits. Other scripts are partially implemented or are placeholders pending implementation.
The scripts are intended for M365 administrators, security/compliance teams, and consultants who want repeatable, script-based reporting. Because not every script is complete, review each script's status and source before use.
Prerequisites
- PowerShell 5.1 or PowerShell 7+. PowerShell 7+ is recommended.
- The relevant Microsoft modules installed, depending on which scripts you run:
- Microsoft Graph PowerShell SDK (
Microsoft.Graph.*) - used by many of the scripts.
- Exchange Online Management (
ExchangeOnlineManagement) - used by the Exchange and several compliance scripts (also provides Connect-IPPSSession).
- Microsoft Teams (
MicrosoftTeams), SharePoint Online (Microsoft.Online.SharePoint.PowerShell), Power BI (MicrosoftPowerBIMgmt), Power Platform (Microsoft.PowerApps.Administration.PowerShell), and Intune modules for the scripts that target those services.
- Appropriate Microsoft 365 administrative roles and, where noted, the required licensing (for example, some Identity Protection and Privileged Identity Management data requires the appropriate Microsoft Entra ID licensing).
Script 00-Install-M365Modules.ps1 is provided to help install required modules.
Authentication & Permissions
Scripts authenticate using the connection method appropriate to the service they target - for example Connect-MgGraph (Microsoft Graph), Connect-ExchangeOnline, Connect-IPPSSession (Security & Compliance), Connect-MicrosoftTeams, Connect-SPOService, Connect-PowerBIServiceAccount, or Add-PowerAppsAccount (Power Platform). The Script Index lists the connection method observed in each script's source.
Where a script includes comment-based help, it documents the specific permissions it requests; run Get-Help .\<script>.ps1 -Full to review them. For scripts that do not yet have help, review the script source directly before running so you can confirm the requested access is appropriate for your environment.
Installation
# 1. Clone the repository
git clone https://github.com/Ryan-Adams57/Microsoft-365-PowerShell-Scripts.git
cd Microsoft-365-PowerShell-Scripts
# 2. Install the required modules
.\00-Install-M365Modules.ps1
Usage
View a script's full help (where comment-based help is present):
Get-Help .\01-Get-M365UserLicenseReport.ps1 -Full
Run a script (you will be prompted to sign in and consent to the requested scopes):
.\01-Get-M365UserLicenseReport.ps1 -ExportPath "C:\Reports\UserLicenses.csv"
Parameter names may vary per script. Check -Full help where available, or the script source, for the exact parameters a given script supports.
Script Index
The repository contains 76 scripts (00-75). The Status column indicates each script's current stage of completion.
Status legend:
- Functional - queries live Microsoft 365 data and produces a real report.
- Partial - retrieves real data for part of the report; some fields use sample/placeholder values pending implementation.
- Placeholder - the script contains scaffolding or sample output, but the reporting logic is not currently retrieving the intended live data.
- Utility - helper script (e.g., module installer).
Functional status is based on source-code review confirming live data-retrieval logic. Scripts have not been individually validated against every Microsoft 365 tenant configuration.
The "Connects via" values reflect the connection method observed in each script's source. For Placeholder scripts, this is the method the script is scaffolded to use once implemented.
| Script | Description | Connects via | Status |
|---|
| 00-Install-M365Modules | Installs the PowerShell modules required by the other scripts | - (module installer) | Utility |
| 01-Get-M365UserLicenseReport | User license assignment report | Microsoft Graph | Functional |
| 02-Get-M365InactiveUsersReport | Inactive users report | Microsoft Graph | Functional |
| 03-Get-M365ExternalForwardingReport | External mail forwarding report | Exchange Online | Functional |
| 04-Get-M365MailboxSizeReport | Mailbox size report | Exchange Online | Functional |
| 05-Get-M365GroupMembershipsReport | Group memberships report | Microsoft Graph | Functional |
| 06-Get-M365OneDriveUsageReport | OneDrive usage report | SharePoint Online + Microsoft Graph | Functional |
| 07-Get-M365SharePointExternalSharingReport | SharePoint external sharing report | SharePoint Online | Partial |
| 08-Search-M365UnifiedAuditLog | Unified audit log search | Exchange Online | Functional |
| 09-Get-M365RoomMailboxUsageReport | Room mailbox usage report | Exchange Online | Functional |
| 10-Get-M365TeamsMeetingAttendanceReport | Teams meeting attendance report | Microsoft Teams | Placeholder |
| 11-Get-M365MFAStatusReport | MFA status report | Microsoft Graph | Functional |
| 12-Get-M365RiskySignInsReport | Risky sign-ins report (Entra ID Identity Protection) | Microsoft Graph | Functional |
| 13-Get-M365GuestUsersAuditReport | Guest users audit report | Microsoft Graph | Placeholder |
| 14-Get-M365PrivilegedRoleAssignmentsReport | Privileged role assignments report | Microsoft Graph | Functional |
| 15-Get-M365ConditionalAccessPoliciesReport | Conditional Access policies report | Microsoft Graph | Functional |
| 16-Get-M365MailFlowRulesReport |