Skip to content

Latest commit

History

153 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

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.

ScriptDescriptionConnects viaStatus
00-Install-M365ModulesInstalls the PowerShell modules required by the other scripts- (module installer)Utility
01-Get-M365UserLicenseReportUser license assignment reportMicrosoft GraphFunctional
02-Get-M365InactiveUsersReportInactive users reportMicrosoft GraphFunctional
03-Get-M365ExternalForwardingReportExternal mail forwarding reportExchange OnlineFunctional
04-Get-M365MailboxSizeReportMailbox size reportExchange OnlineFunctional
05-Get-M365GroupMembershipsReportGroup memberships reportMicrosoft GraphFunctional
06-Get-M365OneDriveUsageReportOneDrive usage reportSharePoint Online + Microsoft GraphFunctional
07-Get-M365SharePointExternalSharingReportSharePoint external sharing reportSharePoint OnlinePartial
08-Search-M365UnifiedAuditLogUnified audit log searchExchange OnlineFunctional
09-Get-M365RoomMailboxUsageReportRoom mailbox usage reportExchange OnlineFunctional
10-Get-M365TeamsMeetingAttendanceReportTeams meeting attendance reportMicrosoft TeamsPlaceholder
11-Get-M365MFAStatusReportMFA status reportMicrosoft GraphFunctional
12-Get-M365RiskySignInsReportRisky sign-ins report (Entra ID Identity Protection)Microsoft GraphFunctional
13-Get-M365GuestUsersAuditReportGuest users audit reportMicrosoft GraphPlaceholder
14-Get-M365PrivilegedRoleAssignmentsReportPrivileged role assignments reportMicrosoft GraphFunctional
15-Get-M365ConditionalAccessPoliciesReportConditional Access policies reportMicrosoft GraphFunctional
16-Get-M365MailFlowRulesReportMail flow (transport) rules reportExchange OnlineFunctional
17-Get-M365SpamMalwareReportSpam and malware detection reportExchange OnlineFunctional
18-Get-M365TeamsLifecycleReportTeams lifecycle reportMicrosoft TeamsFunctional
19-Get-M365TeamsExternalAccessReportTeams external access reportMicrosoft TeamsFunctional
20-Get-M365SharePointInactiveSitesReportInactive SharePoint sites reportSharePoint OnlineFunctional
21-Audit-M365LicenseAssignmentChangesLicense assignment change auditExchange OnlineFunctional
22-Get-M365UnusedLicensesReportUnused licenses reportMicrosoft GraphFunctional
23-Get-M365MailboxPermissionsReportMailbox permissions reportExchange OnlineFunctional
24-Audit-M365FileDeletionReportFile deletion audit reportExchange OnlineFunctional
25-Audit-M365AdminActivityReportAdmin activity audit reportExchange OnlineFunctional
26-Get-M365DefenderThreatProtectionReportDefender threat protection reportExchange OnlineFunctional
27-Get-M365DLPPolicyReportData Loss Prevention policy reportSecurity & Compliance (IPPS) + Exchange OnlineFunctional
28-Get-PowerPlatformEnvironmentReportPower Platform environment reportPower Platform (Add-PowerAppsAccount)Functional
29-Get-PowerAutomateFlowsInventoryPower Automate flows inventoryPower Platform (Add-PowerAppsAccount)Functional
30-Get-PowerAppsUsageReportPower Apps usage reportPower Platform (Add-PowerAppsAccount)Functional
31-Get-PowerBIWorkspaceReportPower BI workspace reportPower BIFunctional
32-Get-IntuneDeviceComplianceReportIntune device compliance reportIntune (Connect-MSGraph)Functional
33-Get-IntuneAppProtectionPoliciesReportIntune app protection policies reportIntune (Connect-MSGraph)Functional
34-Get-AzureADConditionalAccessSignInLogsEntra ID Conditional Access sign-in logsMicrosoft GraphFunctional
35-Get-M365RetentionPoliciesReportRetention policies reportSecurity & Compliance (IPPS)Functional
36-Get-M365eDiscoveryCasesReporteDiscovery cases reportSecurity & Compliance (IPPS)Functional
37-Get-M365SensitivityLabelsReportSensitivity labels reportSecurity & Compliance (IPPS)Functional
38-Get-ExchangeAdvancedMessageTraceAdvanced message traceExchange OnlineFunctional
39-Get-ExchangeJournalingArchivingReportJournaling and archiving reportExchange OnlineFunctional
40-Get-AzureADB2BCollaborationReportEntra ID B2B collaboration reportMicrosoft GraphFunctional
41-Get-AzureADIdentityProtectionReportEntra ID Identity Protection reportMicrosoft GraphFunctional
42-Get-TeamsChannelAnalyticsReportTeams channel analytics reportMicrosoft Teams + Graph + Exchange OnlineFunctional
43-Get-TeamsVoiceCallingReportTeams voice/calling reportMicrosoft Teams + Graph + Exchange OnlinePlaceholder
44-Get-IntuneConfigurationProfilesReportIntune configuration profiles reportMicrosoft Teams + Graph + Exchange OnlinePlaceholder
45-Get-MobileDeviceManagementReportMobile device management reportMicrosoft Teams + Graph + Exchange OnlinePlaceholder
46-Get-CommunicationComplianceReportCommunication compliance reportMicrosoft Teams + Graph + Exchange OnlinePlaceholder
47-Get-InsiderRiskManagementReportInsider risk management reportMicrosoft Graph + Exchange OnlinePlaceholder
48-Get-InformationBarriersReportInformation barriers reportMicrosoft Graph + Exchange OnlinePlaceholder
49-Get-AzureADPIMReportEntra ID Privileged Identity Management reportMicrosoft Graph + Exchange OnlinePlaceholder
50-Get-MicrosoftSecureScoreReportMicrosoft Secure Score reportMicrosoft Graph + Exchange OnlinePlaceholder
51-Get-DefenderEndpointDeviceReportDefender for Endpoint device reportMicrosoft GraphPartial
52-Get-AzureADAppRegistrationsReportEntra ID app registrations reportMicrosoft GraphFunctional
53-Get-ServiceHealthIncidentsReportService health incidents reportMicrosoft GraphFunctional
54-Get-HybridIdentityADConnectReportHybrid identity / AD Connect reportMicrosoft GraphFunctional
55-Get-ComplianceManagerAssessmentsReportCompliance Manager assessments reportMicrosoft GraphPartial
56-Get-VivaInsightsAdoptionReportViva Insights adoption reportMicrosoft GraphPartial
57-Get-M365UsageAnalyticsReportM365 usage analytics reportMicrosoft GraphFunctional
58-Get-NetworkConnectivityReportNetwork connectivity reportMicrosoft GraphPlaceholder
59-Get-BackupPoliciesReportBackup policies reportMicrosoft GraphPlaceholder
60-Get-ServicePrincipalPermissionsReportService principal permissions reportMicrosoft GraphPlaceholder
61-Get-EOPAdvancedConfigReportExchange Online Protection advanced config reportExchange OnlinePlaceholder
62-Get-PowerPlatformDLPPoliciesReportPower Platform DLP policies reportPower Platform (Add-PowerAppsAccount)Placeholder
63-Get-AzureADAccessReviewsReportEntra ID access reviews reportMicrosoft GraphPlaceholder
64-Get-TeamsAppPermissionsReportTeams app permissions reportMicrosoft TeamsPlaceholder
65-Get-SharePointSiteCollectionsReportSharePoint site collections reportSharePoint OnlinePlaceholder
66-Get-ExchangeMailboxDatabasesReportExchange mailbox databases reportExchange OnlinePlaceholder
67-Get-DefenderAttackSimulationReportDefender attack simulation reportMicrosoft GraphPlaceholder
68-Get-AzureADEntitlementManagementReportEntra ID entitlement management reportMicrosoft GraphPlaceholder
69-Get-M365GroupsExpirationReportM365 groups expiration reportMicrosoft GraphPlaceholder
70-Get-IntuneAppInventoryReportIntune app inventory reportIntune (Connect-MSGraph)Placeholder
71-Get-CloudAppSecurityReportCloud App Security (Defender for Cloud Apps) reportMicrosoft GraphPlaceholder
72-Get-M365LicenseUsageTrendsReportLicense usage trends reportMicrosoft GraphPlaceholder
73-Get-SharePointHubSitesReportSharePoint hub sites reportSharePoint OnlinePlaceholder
74-Get-TeamsPoliciesInventoryReportTeams policies inventory reportMicrosoft TeamsPlaceholder
75-Get-AzureADAuthenticationMethodsReportEntra ID authentication methods reportMicrosoft GraphPlaceholder

For exact scopes/permissions and parameters, run Get-Help .\<script>.ps1 -Full where comment-based help is available, or review the script source.

Repository Structure

Scripts are stored in the repository root and numbered 00-75 so they sort in a logical order. Numbers 1-9 are zero-padded (01-09) for correct sorting. The numbering roughly groups related areas together (identity and licensing early on, followed by Exchange, Teams, Intune, Defender, Purview/compliance, and Power Platform).

  • 00-Install-M365Modules.ps1 - module installer helper.
  • 01-75 - individual reporting/auditing scripts (see the Status column for completion state).
  • README.md - this file.
  • LICENSE - repository license.

Known Issues

  • Resolved: Duplicate/extra header comment lines ("extra slashes") in scripts 42-50 have been removed.
  • Resolved:12-Get-M365RiskySignInsReport.ps1 now includes full comment-based help.
  • In progress: Several scripts are placeholders whose reporting logic is scaffolded but not yet connected to live data - they currently produce sample output. A few others are partially implemented. See the Status column in the Script Index for the current state of each script. Implementing these is the focus of the next phase of work.
  • Comment-based help is still being added across the functional scripts (currently only script 12 has it).
  • Validate each script in a non-production tenant before relying on it.

Contributing

Contributions and feedback are welcome:

  • Open an issue to report a bug, request a script, or suggest an improvement. Please include the script name and any error output.
  • Submit a pull request for fixes or enhancements. Keep changes focused, and note any new permissions a script requires.

Acknowledgements

This repository has benefited from thoughtful community feedback. Special thanks to:

Snickasaurus - provided multiple suggestions that directly improved the repository, including:

  • Recommending the creation of 00-Install-M365Modules.ps1 to consolidate module installation across all scripts.
  • Advising zero-padding of scripts 1-9 for proper sorting.
  • Highlighting that 12-Get-M365RiskySignInsReport.ps1 was a template and suggesting clarification.
  • Noting formatting issues (extra slashes) in scripts 42-50.

License

This project is licensed under the terms of the LICENSE file included in this repository.

About

PowerShell scripts for managing, reporting, and auditing Microsoft 365 tenants across Entra ID, Exchange, SharePoint, Teams, Intune, and more.

Topics

Resources

Stars

69 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages