Complete guide to creating comprehensive Microsoft Teams reports using PowerShell and Microsoft Graph.
Automate guest user management, compliance reporting, and security auditing with professional HTML reports.
Why This PowerShell Suite Changes Everything
Managing Microsoft Teams at scale is challenging. With hundreds of teams, thousands of channels, and countless guest users,
administrators need powerful tools to maintain security, ensure compliance, and generate comprehensive reports.
This PowerShell suite solves these challenges with three specialized scripts that automate the entire process.
What You’ll Accomplish
By the end of this guide, you’ll have a complete Microsoft Teams reporting system that generates
professional HTML reports for guest user management, compliance auditing, and security assessment—all automated with PowerShell.
✨ Complete Feature Overview
Guest User Management
Complete inventory of all guest accounts with detailed metadata, risk assessment, and inactive account identification. Perfect for quarterly access reviews and compliance audits.
Teams & Channels Audit
Comprehensive listing of all teams and channels with privacy classifications, membership details, and access control analysis. Essential for security governance.
Compliance Reporting
Automated GDPR, HIPAA, and SOX compliance assessment with actionable recommendations and executive-ready dashboards.
Professional HTML Reports
Beautiful, interactive HTML reports with responsive design, search functionality, and print-friendly layouts. Perfect for presentations and documentation.
Prerequisites and Setup
Before diving into the scripts, ensure you have the necessary prerequisites and permissions set up correctly.
Required Software
- PowerShell 5.1 or later (PowerShell 7+ recommended for best performance)
- Microsoft Graph PowerShell SDK
- Internet connectivity for Microsoft Graph API access
Required Permissions
Permission | Scope | Purpose |
---|---|---|
User.Read.All | Application/Delegated | Read user profiles and guest accounts |
Directory.Read.All | Application/Delegated | Read directory data and organizational info |
Team.ReadBasic.All | Application/Delegated | Read Teams information |
Channel.ReadBasic.All | Application/Delegated | Read channel information |
TeamMember.Read.All | Application/Delegated | Read team memberships |
Policy.Read.All | Application/Delegated | Read compliance policies |
Reports.Read.All | Application/Delegated | Read usage reports |
AuditLog.Read.All | Application/Delegated | Read audit logs for compliance |
⚠️ Important Security Note
These scripts use read-only permissions and never modify or delete data. All authentication is handled securely through Microsoft Graph, and reports are generated locally on your machine.
Step-by-Step Installation Guide
Install Microsoft Graph PowerShell SDK
The first step is installing the Microsoft Graph PowerShell modules. You can install all modules at once or install them individually for better control.
Download the PowerShell Scripts
Clone or download the repository containing all four PowerShell scripts. Each script serves a specific purpose in the reporting suite.
Configure Authentication
Set up authentication method based on your environment. Interactive authentication works for most scenarios, while device code authentication is perfect for server environments.
Run Your First Report
Execute the setup script to install modules and generate your first comprehensive Teams report. The script will guide you through the process.
Quick Installation Commands
# Install all Microsoft Graph modules (recommended) Install-Module Microsoft.Graph -Force -AllowClobber # Or install specific modules for better control Install-Module Microsoft.Graph.Authentication -Force Install-Module Microsoft.Graph.Users -Force Install-Module Microsoft.Graph.Teams -Force Install-Module Microsoft.Graph.Identity.SignIns -Force Install-Module Microsoft.Graph.Reports -Force # Clone the repository git clone https://github.com/yourusername/teams-reporting-suite.git cd teams-reporting-suite # Run the setup script with automatic module installation .\setup-and-run.ps1 -InstallModules -ReportType All
Deep Dive: Understanding Each Script
1. Guest User Report Script (teams-guest-report.ps1)
This script is your comprehensive solution for guest user management and compliance. It retrieves detailed information
about all guest users in your Microsoft 365 tenant and performs risk assessment based on various factors.
Key Functions Explained:
- Get-GuestUsers: Retrieves all guest users with detailed properties including last sign-in, department, job title, and creation date
- Analyze-GuestRisks: Performs comprehensive risk assessment based on activity patterns, account age, and access levels
- Generate-GuestHTML: Creates beautiful, interactive HTML reports with search, filtering, and export capabilities
# Example: Running the guest report with verbose logging .\teams-guest-report.ps1 -Verbose # Using device code authentication for server environments .\teams-guest-report.ps1 -UseDeviceCode # Specifying tenant and client ID for app registration .\teams-guest-report.ps1 -TenantId "your-tenant-id" -ClientId "your-app-id"
Pro Tip
The guest report includes GDPR compliance features, automatically identifying inactive accounts that may need attention for data retention policies.
2. Teams & Channels Report Script (teams-channels-report.ps1)
This script provides complete visibility into your Teams environment, cataloging every team, channel, and membership
relationship. It’s essential for security governance and access control auditing.
What It Discovers:
- Team Inventory: All teams with creation dates, descriptions, and privacy settings
- Channel Analysis: Every channel with privacy classification (Public/Private/Shared)
- Membership Details: Complete member and owner listings for teams and private channels
- Access Patterns: Analysis of who has access to what information
# Generate comprehensive teams and channels report .\teams-channels-report.ps1 # The script automatically: # 1. Connects to Microsoft Graph # 2. Retrieves all teams in the tenant # 3. Gets channels for each team # 4. Collects membership information # 5. Analyzes privacy settings # 6. Generates interactive HTML report
3. Compliance & Security Report Script (teams-compliance-report.ps1)
The crown jewel of the suite, this script performs automated compliance assessment against major regulatory
frameworks including GDPR, HIPAA, and SOX. It provides actionable recommendations and executive-ready dashboards.
Compliance Frameworks Covered:
GDPR Compliance
Data subject rights assessment, consent management review, data retention analysis, and right to be forgotten compliance.
HIPAA Compliance
Access control review, audit logging assessment, data encryption verification, and PHI protection analysis.
SOX Compliance
Financial data access controls, segregation of duties analysis, change management documentation, and audit trail verification.
# Generate comprehensive compliance report .\teams-compliance-report.ps1 # The script performs: # - Guest user risk assessment # - Public team analysis # - External sharing evaluation # - Data retention policy review # - Access control verification # - Compliance gap identification
4. Master Setup Script (setup-and-run.ps1)
This orchestration script simplifies the entire process, handling module installation, authentication,
and report generation. It’s perfect for both one-time runs and automated scheduling.
# Install modules and run all reports .\setup-and-run.ps1 -InstallModules -ReportType All # Run specific report types .\setup-and-run.ps1 -ReportType GuestReport .\setup-and-run.ps1 -ReportType ChannelsReport .\setup-and-run.ps1 -ReportType ComplianceReport # Use device code authentication .\setup-and-run.ps1 -ReportType All -UseDeviceCode
Authentication Methods Explained
Interactive Authentication (Default)
The simplest method for most administrators. The script opens a browser window where you sign in with your
Microsoft 365 credentials. Perfect for desktop environments and one-time report generation.
# Interactive authentication (default behavior) .\teams-guest-report.ps1 # The script will: # 1. Open your default browser # 2. Redirect to Microsoft login page # 3. Request consent for required permissions # 4. Return to PowerShell to continue execution
Device Code Authentication
Ideal for server environments, remote sessions, or when browser authentication isn’t available.
The script provides a code that you enter on another device.
# Device code authentication .\teams-guest-report.ps1 -UseDeviceCode # Process: # 1. Script displays a device code # 2. Navigate to https://microsoft.com/devicelogin on any device # 3. Enter the provided code # 4. Sign in with your credentials # 5. Return to PowerShell session
Application Authentication (Advanced)
For automated scenarios and scheduled reporting, you can register an Azure AD application
and use application credentials.
⚠️ Security Consideration
Application authentication requires careful security planning. Store client secrets securely and follow the principle of least privilege when assigning permissions.
Understanding Your Reports
Guest Accounts Report Features
The guest accounts report provides comprehensive insights into external user access:
- Executive Summary: High-level metrics and key findings
- Detailed User Inventory: Complete list with metadata
- Risk Assessment Dashboard: Color-coded risk levels
- Inactive Accounts Analysis: Users who haven’t signed in recently
- Compliance Recommendations: Actionable next steps
Teams & Channels Report Structure
The teams report organizes information hierarchically for easy navigation:
- Teams Overview: Summary statistics and key metrics
- Privacy Analysis: Breakdown of public vs. private teams
- Channel Inventory: Complete channel listing with privacy settings
- Membership Summary: User access patterns and role assignments
- Security Recommendations: Potential security improvements
Compliance Report Dashboard
The compliance report provides executive-ready insights:
- Compliance Score: Overall compliance rating
- Framework Assessment: GDPR, HIPAA, SOX evaluation
- Risk Matrix: Visual representation of compliance gaps
- Action Plan: Prioritized remediation steps
- Audit Trail: Documentation for compliance officers
✅ Report Quality
All reports feature professional styling, interactive elements, responsive design, and are optimized for both screen viewing and printing. They’re perfect for executive presentations and compliance documentation.
Troubleshooting Common Issues
Module Installation Problems
If you encounter issues installing the Microsoft Graph modules:
# Install for current user if admin rights unavailable Install-Module Microsoft.Graph -Scope CurrentUser -Force # Clear module cache if experiencing conflicts Get-Module Microsoft.Graph* -ListAvailable | Uninstall-Module -Force Install-Module Microsoft.Graph -Force # Check PowerShell execution policy Get-ExecutionPolicy Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Authentication Failures
When authentication doesn’t work as expected:
# Clear cached credentials Disconnect-MgGraph Clear-MgContext # Verify connection status Get-MgContext # Use device code authentication as fallback .\teams-guest-report.ps1 -UseDeviceCode # Enable verbose logging for troubleshooting .\teams-guest-report.ps1 -Verbose
Permission Errors
If you receive permission-related errors:
- Verify you have appropriate admin rights in your Microsoft 365 tenant
- Check that all required Graph API permissions are granted
- Ensure consent has been provided for the application permissions
- Try running with Global Administrator privileges
- Contact your tenant administrator if permissions cannot be granted
Performance Optimization
For large tenants with thousands of users and teams:
- Run during off-peak hours: Reduces API throttling
- Monitor progress indicators: Scripts show real-time progress
- Be patient: Large tenants may take 10-15 minutes per report
- Check system resources: Ensure adequate memory and disk space
Performance Tip
The scripts include built-in retry logic and rate limiting to handle Microsoft Graph API throttling automatically. You don’t need to worry about API limits—just let the scripts run.
Best Practices for Teams Administration
Regular Reporting Schedule
Establish a consistent reporting cadence for optimal Teams governance:
- Monthly: Guest user reports for access review
- Quarterly: Comprehensive compliance assessment
- Bi-annually: Complete teams and channels audit
- As needed: Incident response and security investigations
Compliance Management
Use the reports to maintain ongoing compliance:
- Document everything: Save reports for audit trails
- Track improvements: Compare reports over time
- Act on recommendations: Address high-priority items first
- Involve stakeholders: Share reports with compliance officers
Security Governance
Leverage the insights for better security posture:
- Monitor guest access: Regular review of external users
- Audit team privacy: Ensure appropriate privacy settings
- Review permissions: Validate user access levels
- Track changes: Monitor team and channel modifications
Pro Administrator Tip
Set up Windows Task Scheduler to run these reports automatically. Combined with email notifications,
you can have fresh compliance and security reports delivered to your inbox without manual intervention.
Advanced Usage and Customization
Customizing Report Content
The scripts are designed to be easily customizable. You can modify the HTML templates, add custom fields, or integrate with other systems:
# Example: Adding custom fields to guest report # Modify the Get-GuestUsers function to include additional properties $guestUsers = Get-MgUser -Filter "userType eq 'Guest'" -Property @( 'DisplayName', 'Mail', 'UserPrincipalName', 'CreatedDateTime', 'SignInActivity', 'Department', 'JobTitle', 'CompanyName', 'CustomAttribute1', 'CustomAttribute2' # Add your custom fields )
Integration with Other Tools
The scripts can be integrated with various enterprise tools:
- PowerBI: Export data for advanced analytics
- SharePoint: Store reports in document libraries
- Azure Logic Apps: Automate report distribution
- Microsoft Sentinel: Feed security insights
Automated Scheduling
Set up automated report generation using Windows Task Scheduler:
# Create a batch file for task scheduler @echo off cd /d "C:\Path\To\Scripts" powershell.exe -ExecutionPolicy Bypass -File "setup-and-run.ps1" -ReportType All # Schedule the batch file to run: # - Weekly for guest reports # - Monthly for compliance reports # - Quarterly for comprehensive audits
Ready to Transform Your Teams Administration?
Download the complete PowerShell reporting suite and start generating professional
Microsoft Teams reports in minutes. Perfect for administrators, compliance officers, and security professionals.