Troubleshoot your Azure Virtual Desktop (AVD) or Remote Desktop Environment with the MSRD-Collect tool

I recently stumbled on a cool tool called “MSRD-Collect”. MSRD stands for Microsoft CSS Remote Desktop Data Collection and Diagnostic Script. MSRD-Collect is a PowerShell script with separate modules designed to collect information that will help Microsoft Customer Support Services (CSS) to troubleshoot issues in Azure Virtual Desktop or Remote Desktop Services environments.

MSRD-Collect is not only a handy tool for Microsoft CSS but can be used by AVD or RDS administrators having issues or who want to check the health of their session hosts.  MSRD-Collect can be executed from the AVD session or Remote Desktop hosts. The tool is created and maintained by Robert Klemencz and Alexandru Olariu from Microsoft.

What checks are performed?

The script performs the following diagnostics, from AVD, and RDS (RDP) environments:

  • Overview of the system the script is running on (General information)
  • OS activation / licensing
  • Top 10 processes using the most CPU time on all processors
  • Total and available disk space
  • Graphics configuration
  • Windows Installer information
  • Windows Search information
  • SSL/TLS configuration
  • User Account Control (UAC) configuration
  • Windows Update configuration
  • WinRM and PowerShell configuration/requirements
  • Authentication and Logon information
  • FSLogix configuration and presence of the recommended Windows Defender Antivirus exclusion values for FSLogix (if present)
  • Multimedia configuration (Multimedia Redirection and Audio/Video privacy settings)
  • Remote Desktop client information
  • Remote Desktop licensing configuration
  • RDP and remote desktop listener configuration
  • Information on installed RDS roles and their services (if present)
  • Remote Desktop device and resource redirection configuration
  • Antivirus information (if present)
  • Remote Desktop related security settings and requirements
  • Remote Desktop ‘Session Time Limits’ and other network time limit policy settings
  • AVD host pool information
  • AVD Agent and SxS Stack information
  • Information related to AVD usage on Azure Stack HCI
  • AVD required URLs accessibility
  • AVD services API health status (BrokerURI, BrokerURIGlobal, DiagnosticsUri, BrokerResourceIdURIGlobal)
  • RDP ShortPath configuration (Windows 10+ and Server OS) for both managed and public networks
  • Azure AD-join configuration
  • Check for Domain Controller configuration (trusted and available)
  • DNS configuration (Windows 10+ and Server OS)
  • Firewall configuration (Firewall software available inside the VM – does not apply to external firewalls)
  • Proxy and route configuration
  • Public IP address information
  • VPN connection profile information
  • Various settings that are sometimes related to Black Screen logon scenarios
  • Installed Citrix software and some other 3rd party components potentially running on the system, which may be relevant in various troubleshooting scenarios
  • Microsoft Office Configuration
  • OneDrive configuration and requirements for FSLogix compatibility
  • Printing information (spooler service status, available printers)
  • Teams information and AVD media optimization configuration for Teams (if present)
  • Known AVD agent-related issues over the past 5 days
  • Known FSLogix-related issues over the past 5 days
  • Known MSIX App Attach related issues over the past 5 days
  • Known RDP ShortPath issues over the past 5 days
  • Known Black Screen issues over the past 5 days
  • Known TCP issues over the past 5 days
  • Known Process and system crashes over the past 5 days
  • Known Process hangs over the past 5 days

The data collected is not uploaded to Microsoft!

How to run the MSRD-Collect tool?

  • Download MSRD-Collect, link. or use the following URL:
https://aka.ms/avd-collect
  • Extract the zip file
  • Set the PowerShell execution mode:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force -Scope Process
  • Unblock the files
Get-ChildItem -Recurse -Path C:\MSRD_Path\Modules\*.ps* | Unblock-File -Confirm:$false
  • MSRD-Collect can be run from the command line or with GUI. To run MSRD-Collect with a GUI, execute:
    • MSRD-Collect.ps1 in a PowerShell session with elevated permissions in order to collect all required data
  • Select AVD or RDS as a source and click on Start to begin gathering data

  • The data will default be stored in the  c:\MSDATA folder. This can be changed in the GUI or when running from the command line
  • When the script finishes. a nice HTML page (<servername_MSRD-Diag.HTML)  is generated:

The output contains all settings and links to other log files. Sections marked in Yellow need attention. For example, to view the latest Windows Updates installed, click on the Updates Section and then UpdateHistory.html:

Conclusion

MSRD-Collect is definitely a tool that every AVD or RDS administrator must have in their toolbox. MSRD-Collect gives great detailed information about the state of the AVD/RDS environment and makes troubleshooting a lot easier. With the command line option, you can schedule the script to run at regular times.

Make sure you run this tool before calling Microsoft CSS when having issues with your AVD or RDS environment.

Quick Tip – Download the Azure Virtual Desktop RDPW files

Sometimes you need the RDPW files when having for example remote apps listed in a central portal application integration. Here is a quick tip on how to download the Azure Virtual Desktop RDPW files for desktops and remote apps.

1. Log in using the AVD WebClient using the following URL: https://client.wvd.microsoft.com/arm/webclient/index.html

2. In the right corner click on the Settings wheel

3. Select in “Resources Launch Method” section for “Download the rdp file”

4. Close the screen by clicking on the X mark

5. Click on the remote app or desktop to download the RDPW file

 

Optimize the Azure Virtual Desktop (AVD) golden image automatically

For Azure Virtual Desktop (AVD) there is an Optimization Tool available called Virtual Desktop Optimization Tool (VDOT). With this tool/script you optimize the following categories within an Azure Virtual Desktop (AVD):

    • Universal Windows Platform (UWP) app cleanup
    • Optional Features cleanup
    • Local policy settings
    • System services
    • Scheduled tasks
    • Apply Windows (and other) updates
    • Automatic Windows traces
    • Windows Defender optimization
    • Client network performance tuning by registry settings
    • Additional settings from the “Windows Restricted Traffic Limited Functionality Baseline” guidance.
    • Disk cleanup

Optimizing the AVD Golden Image will improve the User Experience, so it is highly recommended to use it. Vendors such as VMware (VMware OS Optimization Tool) and Citrix (Citrix Optimizer Tool) use their own tools for optimizing their Golden Images.

To optimize an AVD image you must do some things manually before you run the Virtual Desktop Optimization Tool (VDOT). I created a PowerShell script that downloads the latest VDOT and optimizes the AVD image automatically.

The PowerShell script below does the following:

  • Create a folder on the AVD  VM called c:\optimize
  • Download the latest Virtual Desktop Optimization Tool
  • Expand the Virtual Desktop Optimization Tool  zip file to the c:\optimize folder
  • Remove the VDOT Archive file
  • Download a modified apppackages.json file. The default apppackages.json file will enable all the APPX packages.
  • Copy the apppackages.json file to the configuration folder for each build
  • Unblock all the downloaded files
  • Execute the Virtual Desktop Optimization Tool
  • Remove the c:\optimize folder
  • Reboot the AVD host
<#
    .SYNOPSIS
        Virtual Desktop Optimalization Tool (VDOT)
    .DESCRIPTION
        Download the Virtual Desktop Optimalization Tool (VDOT), creates a folder called optimize and runs VDOT tool.
        The VDOT tool determines OS version at run-time
    .NOTES
        Version:        1.0
        Author:         Ivo Beerens
                        info@ivobeerens.nl
        Creation Date:  25-02-2022
        Plattform:      Azure VIrtual Desktop (AVD)
        Changelog:      
                        25-05-2022      1.0 - Initial script development
    .COMPONENT

    .LINK
 
    .Example
        Script needs to be run with PowerShell elevated
#>

# Variables
$verbosePreference = 'Continue'
$vdot = 'https://github.com/The-Virtual-Desktop-Team/Virtual-Desktop-Optimization-Tool/archive/refs/heads/main.zip' 
$apppackages = 'https://raw.githubusercontent.com/ibeerens/AVD/main/vdot/ConfigFiles/AppxPackages.json'
$vdot_location = 'c:\Optimize' 
$vdot_location_zip = 'c:\Optimize\vdot.zip'
$apppackages_location = 'C:\Optimize\AppxPackages.json'

# Enable TLS 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

# Clear screen
Clear

# Create Folder
$checkdir = Test-Path -Path $vdot_location
if ($checkdir -eq $false){
    Write-Verbose "Creating '$vdot_location' folder"
    New-Item -Path 'c:\' -Name 'Optimize' -ItemType 'directory' | Out-Null
}
else {
    Write-Verbose "Folder '$vdot_location' already exists."
}

# Download VDOT
Write-Verbose "Dowmload VDOT" 
Invoke-WebRequest -Uri $vdot -OutFile $vdot_location_zip

# Expand Archive
Write-Verbose "Expand Archive" 
Expand-Archive $vdot_location_zip -DestinationPath $vdot_location -Verbose -Force

# Remove Archive
Write-Verbose "Remove Archive" 
Remove-Item $vdot_location_zip

# Download AppPackages
Write-Verbose "Dowmload Apppackages.json APPX file" 
Invoke-WebRequest -Uri $apppackages -OutFile $apppackages_location

# Copy the AppPackage file to all versions
Write-Verbose "Copy Apppackages.json to all configurationfiles folders" 
Copy-Item $apppackages_location -Destination 'C:\Optimize\Virtual-Desktop-Optimization-Tool-main\1909\ConfigurationFiles\AppxPackages.json'
Copy-Item $apppackages_location -Destination 'C:\Optimize\Virtual-Desktop-Optimization-Tool-main\2004\ConfigurationFiles\AppxPackages.json'
Copy-Item $apppackages_location -Destination 'C:\Optimize\Virtual-Desktop-Optimization-Tool-main\2009\ConfigurationFiles\AppxPackages.json'

# Unblock all files
Write-Verbose "Unblock all files" 
dir $vdot_location -Recurse | Unblock-File

# Change folder to VDOT
Write-Verbose "Change folder to VDOT location" 
$vdot_folder = $vdot_location + '\Virtual-Desktop-Optimization-Tool-main' 
cd $vdot_folder

Write-Verbose "Run VDOT" 
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process -Force
.\Windows_VDOT.ps1 -Verbose -AcceptEULA

# Sleep 5 seconds
sleep 5

# Remove folder
Write-Verbose "Remove Optimize folder" 
cd \
Remove-Item $vdot_location -Recurse -Force

# Restart AVD Golden image
Restart-Computer -Force

You can use this script in your AVD Golden Image building process. The Virtual Desktop Optimization Tool (VDOT) changes a lot of settings so be sure to test your image very carefully. The script can be found on my GitHub, link.