Managing Azure Virtual Desktop (AVD) at scale means juggling performance, user experience, and cost. While Auto-Shutdown is a fantastic tool for dev environments, it can be a nightmare in production—unexpectedly kicking users off or causing session hosts to be unavailable during a crunch.
If you’ve tried to disable these schedules using standard “Update VM” scripts only to find the schedules are still active in the portal, you aren’t alone. Today, we’re breaking down why those scripts fail and how to fix it for your entire host pool.
The “Hidden” Resource Problem
When you toggle “Auto-shutdown” in the Azure Portal, it doesn’t just change a setting on your Virtual Machine. Instead, Azure creates a separate, linked resource of the type: microsoft.devtestlab/schedules
Standard PowerShell modules like Az.Compute often ignore these external schedules. To truly disable the feature, you must delete the schedule resource itself.
Scaling the Solution
In an AVD environment, your session hosts are usually grouped in a Host Pool. A manual cleanup would involve clicking through every single VM—a recipe for human error.
Instead, we can use a script that:
- Queries the Host Pool for all active session hosts.
- Predicts the schedule’s name (Azure defaults to
shutdown-computevm-[VMName]). - Deletes the schedule resource directly.
The “Clean Sweep” PowerShell Script
Use this script to iterate through your host pool and remove every auto-shutdown schedule in one go.
PowerShell
# ==============================
# CONFIGURATION
# ==============================
$resourceGroup = "your-avd-rg"
$hostPool = "your-host-pool-name"
# 1. Fetch all session hosts from the AVD Host Pool
$sessionHosts = Get-AzWvdSessionHost -ResourceGroupName $resourceGroup -HostPoolName $hostPool
Write-Host "Found $($sessionHosts.Count) hosts in pool $hostPool. Starting cleanup..." -ForegroundColor Cyan
foreach ($sh in $sessionHosts) {
# Extract the VM name from the session host ID
$vmName = (($sh.Name -split "/")[-1]).Split(".")[0]
try {
# 2. Define the expected shutdown resource name
$shutdownResourceName = "shutdown-computevm-$vmName"
# 3. Locate the schedule resource
$shutdownResource = Get-AzResource -ResourceGroupName $resourceGroup `
-ResourceName $shutdownResourceName `
-ResourceType "microsoft.devtestlab/schedules" `
-ErrorAction SilentlyContinue
if ($shutdownResource) {
Write-Host "Removing auto-shutdown for: $vmName" -ForegroundColor Yellow
Remove-AzResource -ResourceId $shutdownResource.ResourceId -Force -Confirm:$false
Write-Host "Successfully disabled!" -ForegroundColor Green
}
else {
Write-Host "No active schedule found for $vmName." -ForegroundColor Gray
}
} catch {
Write-Error "Could not process $vmName : $_"
}
}
Pro-Tips for AVD Admins
- Run as a Dry Run: If you’re nervous about mass-deleting, add
-WhatIfto theRemove-AzResourcecommand to see what would happen without actually making changes. - Check Your Permissions: Ensure your account (or the Service Principal running this) has “Contributor” or “Owner” rights on the resource group.
- Alternative: Use Scaling Plans: If you’re disabling auto-shutdown because it’s too rigid, consider switching to AVD Scaling Plans. They are built specifically for Virtual Desktop workloads and can shut down VMs based on session occupancy rather than a hard clock time.
Final Thoughts
In the cloud, “settings” aren’t always just settings—sometimes they are independent resources. Understanding the relationship between your session hosts and their management schedules is the key to a stable, automated AVD environment.

