Skip to content

Microsoft 365 Connection Speed Test

directorcia edited this page Jul 22, 2025 · 3 revisions

Overview

The test-m365-connect-speed.ps1 script is a comprehensive PowerShell tool designed to test network connectivity, performance, and authentication status for Microsoft 365 services. It provides detailed analysis of connection quality, latency, and bandwidth to help diagnose M365 connectivity issues.

Features

Core Testing Capabilities

  • DNS Resolution Testing: Measures time to resolve M365 service domains
  • Port Connectivity Testing: Verifies TCP connections to M365 endpoints
  • HTTPS Response Testing: Tests HTTP/HTTPS response times and status codes
  • Bandwidth Testing: Optional download speed testing via M365 endpoints
  • Authentication Testing: Optional testing of authenticated M365 API calls
  • Public IP Detection: Identifies the workstation's public IP address

Data Security & Upload

  • Secure Azure Blob Storage Upload: Anonymous, secure upload to CIAOPS storage
  • Unlimited Upload Quota: No restrictions on number of uploads
  • Private Storage: Uploaded files are not publicly accessible
  • Data Anonymization: User identifiers are hashed for privacy

Output Formats

  • Console Output: Real-time colored console display
  • HTML Report: Interactive, responsive web report with charts
  • CSV Export: Structured data for analysis
  • JSON Export: Machine-readable format for integration

Installation & Prerequisites

Required PowerShell Version

  • PowerShell 5.1 or later (PowerShell 7+ recommended)

Optional Modules (for enhanced authentication testing)

# Microsoft Graph PowerShell
Install-Module Microsoft.Graph -Scope CurrentUser

# Exchange Online Management
Install-Module ExchangeOnlineManagement -Scope CurrentUser

# SharePoint Online Management
Install-Module Microsoft.Online.SharePoint.PowerShell -Scope CurrentUser

# Microsoft Teams PowerShell
Install-Module MicrosoftTeams -Scope CurrentUser

Network Requirements

  • Internet connectivity
  • Access to Microsoft 365 endpoints (ports 80, 443)
  • Firewall/proxy allowing connections to M365 services

Usage Examples

Basic Connection Test

.\test-m365-connect-speed.ps1

Tests all M365 endpoints with default settings and generates an HTML report.

Comprehensive Test with Bandwidth

.\test-m365-connect-speed.ps1 -IncludeBandwidthTest -TestDuration 30

Includes bandwidth testing for 30 seconds per endpoint.

Authentication-Enhanced Testing

.\test-m365-connect-speed.ps1 -IncludeAuthentication

Prompts for M365 authentication and tests API access.

Export to Specific Format

.\test-m365-connect-speed.ps1 -OutputFormat CSV -OutputPath "C:\Reports\m365-test.csv"

Exports results to CSV format at specified location.

Upload Results to CIAOPS

.\test-m365-connect-speed.ps1 -UploadResults

Automatically uploads results to CIAOPS for analysis.

View Upload Statistics

.\test-m365-connect-speed.ps1 -ShowUploadStats

Displays current upload quota and usage statistics.

Detailed Logging

.\test-m365-connect-speed.ps1 -DetailedLogging

Enables detailed transcript logging to file.

Parameters Reference

Parameter Type Default Description
TestDuration Int 10 Duration in seconds for bandwidth testing (5-300)
IncludeBandwidthTest Switch False Include bandwidth/speed testing
OutputFormat String "HTML" Output format: Console, CSV, JSON, HTML
OutputPath String Auto Custom path for output files
DetailedLogging Switch False Enable detailed logging to file
IncludeAuthentication Switch False Include M365 authentication testing
SkipAuthenticationCheck Switch False Skip checking existing authentication
UploadResults Switch False Upload results to CIAOPS Azure storage
ShowUploadStats Switch False Display upload statistics and quota

Tested Microsoft 365 Services

Core Services

  1. Exchange Online

    • Primary: outlook.office365.com
    • Secondary: outlook.office.com
    • Port: 443 (HTTPS)
  2. SharePoint Online

    • Primary: sharepoint.com
    • Secondary: *.sharepoint.com
    • Port: 443 (HTTPS)
  3. Microsoft Teams

    • Primary: teams.microsoft.com
    • Secondary: teams.live.com
    • Port: 443 (HTTPS)
  4. OneDrive for Business

    • Primary: onedrive.live.com
    • Secondary: *.files.1drv.com
    • Port: 443 (HTTPS)
  5. Azure Active Directory

    • Primary: login.microsoftonline.com
    • Secondary: login.windows.net
    • Port: 443 (HTTPS)
  6. Office Online

    • Primary: office.com
    • Secondary: www.office.com
    • Port: 443 (HTTPS)
  7. Microsoft Graph

    • Primary: graph.microsoft.com
    • Secondary: graph.windows.net
    • Port: 443 (HTTPS)
  8. Power Platform

    • Primary: make.powerapps.com
    • Secondary: powerapps.microsoft.com
    • Port: 443 (HTTPS)
  9. Microsoft Viva

    • Primary: myanalytics.microsoft.com
    • Secondary: insights.viva.office.com
    • Port: 443 (HTTPS)
  10. Microsoft Purview

    • Primary: compliance.microsoft.com
    • Secondary: purview.microsoft.com
    • Port: 443 (HTTPS)

Test Execution Flow

1. Initialization Phase

  • Parameter validation and default value assignment
  • Logging setup (if detailed logging enabled)
  • Azure upload configuration loading
  • Public IP address detection

2. Authentication Phase (if enabled)

  • Check existing authentication status for M365 services
  • Prompt for interactive authentication if needed
  • Establish connections to requested services

3. Connectivity Testing Phase

For each M365 endpoint:

  • DNS Resolution Test: Measure domain name resolution time
  • Port Connectivity Test: Test TCP connection to port 443
  • HTTPS Response Test: Send HTTP request and measure response time
  • Authentication Test: Test API access (if authenticated)

4. Bandwidth Testing Phase (if enabled)

  • Test download speeds using stable M365 endpoints
  • Measure throughput and connection stability
  • Calculate average speeds across multiple requests

5. Results Processing Phase

  • Calculate summary statistics and connection quality ratings
  • Generate output in requested format(s)
  • Display results and recommendations

6. Upload Phase (optional)

  • Prompt user for upload consent (interactive mode)
  • Generate HTML report for upload if needed
  • Securely upload to CIAOPS Azure Blob Storage
  • Display upload confirmation and statistics

Connection Quality Ratings

The script provides automatic connection quality assessment based on average latency:

Rating Latency Range Description User Experience
Excellent < 100ms Outstanding performance Ideal for real-time collaboration and video conferencing
Good 100-199ms Very responsive Suitable for most M365 activities including Teams calls
Fair 200-299ms Noticeable delays Minor delays in real-time applications
Poor 300-499ms Significant delays Video calls may be choppy, slower file operations
Very Poor ≥ 500ms Severe delays Productivity impact, network optimization needed

Output Formats

HTML Report Features

  • Interactive Dashboard: Real-time metrics with color-coded status
  • Responsive Design: Mobile and desktop optimized
  • Visual Charts: Latency distribution and performance trends
  • Service Details: Comprehensive breakdown per M365 service
  • Recommendations: Automated suggestions based on test results
  • Export Options: Print-friendly and shareable format

CSV Export Structure

Service,Endpoint,Description,OverallSuccess,TotalLatency,DNSSuccess,DNSTime,PortSuccess,PortTime,HTTPSSuccess,HTTPSTime,HTTPSStatus,AuthSuccess,AuthTime,AuthInfo,WorkstationPublicIP

JSON Export Structure

{
  "Summary": {
    "TestStart": "datetime",
    "TestEnd": "datetime",
    "TotalEndpoints": "number",
    "SuccessfulConnections": "number",
    "FailedConnections": "number",
    "AverageLatency": "number",
    "MaxLatency": "number",
    "MinLatency": "number"
  },
  "TestResults": [...],
  "BandwidthResults": [...],
  "AuthenticationStatus": {...}
}

Security and Privacy

Data Protection

  • Anonymous Identification: User identifiers are SHA256 hashed
  • No Personal Data: No personally identifiable information collected
  • Secure Transmission: All uploads use HTTPS encryption
  • Private Storage: Uploaded files stored in private Azure containers

Upload Security Features

  • Write-Only Access: SAS tokens only allow file upload
  • No Public Access: Uploaded files cannot be viewed by others
  • Unique File Names: Each upload gets a randomized, unique identifier
  • Time-Limited Access: SAS tokens have expiration dates

Network Security

  • Firewall Friendly: Uses standard HTTPS ports (80, 443)
  • Proxy Compatible: Works through corporate proxies
  • No Admin Rights: Runs with standard user permissions

Troubleshooting

Common Issues

DNS Resolution Failures

  • Symptom: DNS tests fail consistently
  • Causes: Corporate DNS restrictions, firewall blocking
  • Solutions:
    • Check DNS server configuration
    • Verify M365 URLs are not blocked
    • Test from different network location

Port Connectivity Issues

  • Symptom: Port 443 connections fail
  • Causes: Firewall restrictions, proxy configuration
  • Solutions:
    • Review firewall rules for M365 endpoints
    • Configure proxy settings if required
    • Check corporate network policies

Authentication Failures

  • Symptom: M365 service authentication fails
  • Causes: Missing PowerShell modules, MFA requirements
  • Solutions:
    • Install required PowerShell modules
    • Use modern authentication methods
    • Configure conditional access policies

Upload Failures

  • Symptom: Results upload to CIAOPS fails
  • Causes: Network connectivity, proxy issues
  • Solutions:
    • Check internet connectivity
    • Verify proxy settings allow Azure Blob Storage
    • Try upload from different network

Performance Optimization

For Better Test Accuracy

  • Run tests during normal business hours
  • Test from primary work location/network
  • Avoid running during network maintenance windows
  • Close bandwidth-intensive applications

For Faster Execution

  • Skip bandwidth testing for quick results
  • Disable authentication testing if not needed
  • Use console output format for speed
  • Run without detailed logging

Script Architecture

Core Functions

Network Testing Functions

  • Test-DNSResolution: DNS lookup timing
  • Test-PortConnectivity: TCP connection testing
  • Test-HTTPSConnection: HTTP response testing
  • Test-HTTPSRequest: Low-level HTTP request handling

Authentication Functions

  • Test-M365Authentication: Check authentication status
  • Connect-M365Services: Interactive service connection
  • Test-AuthenticatedEndpoint: API access validation

Utility Functions

  • Get-PublicIPAddress: External IP detection
  • Format-LocalDateTime: Localized date formatting
  • Write-TestProgress: Progress indication

Output Functions

  • New-HTMLReport: Generate interactive HTML reports

Upload Functions

  • Upload-ToAzureBlob: Secure Azure Blob Storage upload

Configuration

Azure Upload Configuration

$AzureUploadConfig = @{
    SasUrl = "https://m365testresults.blob.core.windows.net/m365-metric-uploads?[SAS_TOKEN]"
    ContainerName = "m365-metric-uploads"
    StorageAccount = "m365testresults"
}

Endpoint Configuration

All M365 endpoints are configured in the $M365Endpoints hashtable with:

  • Primary and secondary endpoints
  • Port numbers
  • Protocol specifications
  • Service descriptions

Best Practices

For IT Administrators

  1. Regular Testing: Run weekly connectivity tests
  2. Baseline Establishment: Document normal performance metrics
  3. Trend Monitoring: Track performance changes over time
  4. Documentation: Maintain test results for troubleshooting

For End Users

  1. Test Before Issues: Run tests when experiencing problems
  2. Multiple Locations: Test from different network locations
  3. Time Variations: Test at different times of day
  4. Share Results: Upload results to help improve global insights

For Network Optimization

  1. DNS Optimization: Implement local DNS caching
  2. Bandwidth Management: Monitor and optimize bandwidth usage
  3. Proxy Configuration: Ensure optimal proxy settings
  4. Firewall Rules: Maintain current M365 endpoint allowlists

Integration Options

Automated Monitoring

# Daily automated test with upload
.\test-m365-conne-speed.ps1 -UploadResults -OutputFormat JSON -OutputPath "C:\Monitoring\m365-$(Get-Date -Format 'yyyy-MM-dd').json"

PowerShell Script Integration

# Programmatic usage
$results = .\test-m365-connect-speed.ps1 -OutputFormat JSON
$summary = $results.Summary
if ($summary.AverageLatency -gt 200) {
    # Trigger alert or remediation
}

Task Scheduler Integration

  • Schedule regular automated tests
  • Email results to IT team
  • Integrate with monitoring systems

Version History & Updates

Current Version: 1.0

  • Release Date: July 2025
  • Features: Complete M365 connectivity testing suite
  • Security: Azure Blob Storage integration
  • Platforms: PowerShell 5.1+ on Windows

Planned Enhancements

  • PowerShell Core support for cross-platform testing
  • Additional M365 service endpoint coverage
  • Advanced analytics and AI-powered insights
  • Integration with Azure Monitor and Log Analytics

Support and Contact

CIAOPS Support

Community Resources

License and Disclaimer

This script is provided as-is for testing and diagnostic purposes. While it follows Microsoft recommended practices for M365 connectivity testing, results should be interpreted in the context of your specific network environment and requirements.

The script uploads anonymized data to help improve global M365 connectivity insights. All data is handled in accordance with privacy best practices and is not used for any commercial purposes beyond improving the service.


Documentation last updated: July 21, 2025 Script version: 1.0 Author: CIAOPS

Clone this wiki locally