PowerShell script for diagnosing Azure Virtual Desktop (AVD) connectivity issues and disconnects from end-user devices. Performs extensive network testing without requiring Azure credentials.
- Identifies active connection type (Wi-Fi, Ethernet, VPN)
- Displays link speed, IP/MAC addresses
- Shows Wi-Fi SSID and signal strength
- Warns about power management settings that cause disconnects
- Detects problematic configurations
Tests 9 Azure Virtual Desktop endpoints:
rdgateway-r0.wvd.microsoft.comrdgateway-r1.wvd.microsoft.comrdgateway-g-us-r0.wvd.microsoft.comrdgateway-g-us-r1.wvd.microsoft.comrdbroker.wvd.microsoft.comrdweb.wvd.microsoft.comrdgateway.wvd.microsoft.com(redirect server)licensing.rd.microsoft.com(RDP licensing)diagnostics.wvd.microsoft.com(diagnostics)
Per-endpoint tests:
- DNS resolution
- TCP port 443 connectivity
- HTTPS endpoint response
- Network latency (ping time)
- Packet loss (20 packet test)
- Network jitter (latency variance)
- Connection stability (detects resets/timeouts)
- MTU size (fragmentation detection)
- Azure AD Authentication Tests - Verifies login.microsoftonline.com, graph.microsoft.com, auth.gfx.ms connectivity
- WebSocket Connectivity - Tests RDP Web Client support and protocol upgrade capability
- DNS Resolution Consistency - Detects split-DNS, round-robin, and DNS consistency issues
- TCP Reset Statistics - Analyzes connection resets, TIME_WAIT states, and system event logs
- UDP Connectivity - Tests ports 3478, 3479, 3390 for RDP Shortpath
- Time Synchronization - Detects clock drift causing auth failures
- DNS Cache & TTL - Identifies stale DNS issues
- Connection Broker Stress Test - Tests broker stability under load
- Background Network Activity - Detects bandwidth-heavy applications
- Network Adapter Power Management - Identifies sleep settings causing disconnects
- IPv4 vs IPv6 Testing - Compares protocol performance
- Sustained Connection Test - 30 seconds of continuous monitoring to catch intermittent drops
- Color-coded console output (Green/Yellow/Red)
- Detailed log files - One timestamped log per test run
- CSV export - Daily summary file for trending in Excel
- Success rate calculations
- Actionable recommendations for identified issues
Important
PowerShell 7.0 or later is required - PowerShell 5.1 is NOT supported
- Windows 10/11 or Windows Server
- Internet connectivity
- Administrator privileges recommended (for full diagnostics)
This script requires PowerShell 7 for improved performance and reliability.
Option 1: Using Windows Package Manager (Recommended)
winget install Microsoft.PowerShellOption 2: Direct Download
Download and install from: https://aka.ms/powershell
Verify Installation
pwsh -VersionYou should see version 7.0 or higher.
- Go to Test-AVDEndUserConnectivity.ps1
- Click the "Raw" button (top right)
- Right-click → "Save As..." → Save to your desired location
- Or use PowerShell to download directly:
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/colinweiner111/AVD-Connectivity-Test/master/Test-AVDEndUserConnectivity.ps1" -OutFile "Test-AVDEndUserConnectivity.ps1"- Run with PowerShell 7:
pwsh .\Test-AVDEndUserConnectivity.ps1- Go to https://github.com/colinweiner111/AVD-Connectivity-Test
- Click the green "Code" button
- Select "Download ZIP"
- Extract the ZIP file to your desired location
git clone https://github.com/colinweiner111/AVD-Connectivity-Test.git
cd AVD-Connectivity-TestAfter downloading, unblock the script to allow execution:
Unblock-File -Path .\Test-AVDEndUserConnectivity.ps1Run with default settings (tests every 5 minutes):
pwsh .\Test-AVDEndUserConnectivity.ps1Test every 3 minutes:
pwsh .\Test-AVDEndUserConnectivity.ps1 -IntervalMinutes 3Save logs to a specific directory:
pwsh .\Test-AVDEndUserConnectivity.ps1 -LogPath "C:\AVD-Logs".\Test-AVDEndUserConnectivity.ps1 -IntervalMinutes 10 -LogPath "C:\Logs"Press Ctrl+C to stop monitoring
- Format:
AVD-Connectivity-YYYYMMDD-HHMMSS.log - Location: Script directory or custom
-LogPath - Content: Detailed timestamped test results
- Example:
AVD-Connectivity-20251124-143022.log
- Format:
AVD-Connectivity-Summary-YYYYMMDD.csv - Location: Same as log files
- Content: Aggregated metrics for trending analysis
- Updates: Appends new row after each test run
- Timestamp
- Overall success rates
- Per-endpoint DNS/TCP/HTTPS status
- Latency, packet loss, jitter metrics
- Connection stability percentages
Import into Excel to:
- Create charts showing performance over time
- Identify patterns (e.g., disconnects at specific times)
- Compare Wi-Fi vs Ethernet performance
- Present evidence to network teams
| Parameter | Type | Default | Description |
|---|---|---|---|
IntervalMinutes |
Integer | 5 | Time in minutes between each connectivity test |
LogPath |
String | Script directory | Path where log files will be saved |
Symptom: Random disconnects after periods of inactivity
Detection: Script warns if "Allow computer to turn off device to save power" is enabled
Fix: Disable power management in adapter properties
Symptom: Higher latency and jitter compared to Ethernet
Detection: Script identifies connection type and signal strength
Fix: Switch to Ethernet or improve Wi-Fi signal
Symptom: Poor video/audio quality, high latency
Detection: UDP ports 3478-3479 unreachable
Fix: Open UDP ports in firewall for RDP Shortpath
Symptom: Authentication failures, session drops
Detection: Clock drift exceeds acceptable threshold
Fix: Enable and restart Windows Time service
Symptom: Choppy experience, frequent disconnects
Detection: Packet loss percentage >5%
Fix: Check network hardware, ISP connection quality
Symptom: Slow connection establishment, delays
Detection: IPv6 latency significantly higher than IPv4
Fix: Disable IPv6 or fix IPv6 routing
- 100% - All tests passed (optimal)
- 90-99% - Minor issues detected
- 70-89% - Significant issues present
- <70% - Severe connectivity problems
- <50ms - Excellent
- 50-100ms - Good
- 100-200ms - Fair
- >200ms - Poor (may cause disconnect issues)
- 0% - Optimal
- <5% - Minimal (acceptable)
- 5-15% - Moderate (may cause issues)
- >15% - High (will cause disconnects)
- <5ms - Excellent
- 5-15ms - Acceptable
- 15-30ms - Moderate
- >30ms - High (causes quality issues)
Error: "Execution of scripts is disabled on this system"
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserSome tests require administrator privileges. Run PowerShell as Administrator for complete diagnostics.
If your organization blocks PowerShell scripts, work with IT to whitelist this script or run in approved environment.
Contributions are welcome! Please feel free to submit issues or pull requests.
- Email/webhook alerting on failures
- Baseline comparison (alert on deviation)
- Additional cloud environments (GCC High, DoD)
- Session host testing (for VPN-connected users)
This project is licensed under the MIT License - see the LICENSE file for details.
Created for diagnosing Azure Virtual Desktop connectivity issues in enterprise environments.
- Initial release
- Complete AVD gateway testing suite
- Advanced disconnect diagnostics
- CSV export for trending
- Network interface detection
- Power management checks
- IPv6 testing
- Sustained connection monitoring
For issues, questions, or feature requests, please open an issue on GitHub.
- Microsoft Azure Virtual Desktop documentation
- PowerShell community for networking cmdlets
- Network troubleshooting best practices
- AVD Overview and Architecture
- Network Connectivity Requirements
- RDP Shortpath for Public Networks
- Required URLs and Endpoints
- Troubleshoot Connections to Azure Virtual Desktop
- Diagnose Graphics Performance Issues
- Azure Virtual Desktop Insights
┌─────────────────┐
│ End User │
│ Device │ ← This script tests from here
└────────┬────────┘
│ Internet Connection
│ (Wi-Fi/Ethernet/VPN)
│
▼
┌─────────────────────────────────────────────┐
│ Azure Virtual Desktop Gateway │
│ - rdgateway.wvd.microsoft.com │
│ - rdbroker.wvd.microsoft.com │
│ - rdweb.wvd.microsoft.com │
│ │
│ Public Endpoints │
│ - Port 443 (HTTPS/Gateway) │
│ - Ports 3478/3479 (STUN/TURN) │
│ - Port 3390 (UDP RDP Shortpath) │
└────────┬────────────────────────────────────┘
│ Azure Backbone Network
│ (Private/Optimized)
│
▼
┌─────────────────────────────────────────────┐
│ Session Hosts (Private VNet) │
│ - Windows 10/11 Multi-session │
│ - Windows Server │
│ - Private IP Addresses │
└─────────────────────────────────────────────┘
Test Coverage:
✓ User Device → Gateway (All tests)
✗ Gateway → Session Host (Managed by Azure)
- User initiates connection → Contacts AVD Gateway
- Authentication → Azure AD validates user
- Broker assignment → Determines which session host to use
- Gateway establishes tunnel → Connects to session host
- RDP session begins → User sees their desktop
- 🔴 User's Internet Connection (Most Common) - Poor Wi-Fi, ISP issues
- 🔴 Network Adapter Power Management - Device goes to sleep
- 🔴 UDP Blocked - Forces TCP fallback (slower, less stable)
- 🟡 High Latency/Jitter - Network congestion
- 🟡 DNS Issues - Stale cache, slow resolution
- 🟢 Azure Gateway/Session Host (Rare) - Azure manages reliability
This script focuses on identifying issues in the user-controllable areas (red/yellow zones).
Note: This script is for diagnostic purposes only and does not modify any system settings without user intervention.