SOLVED

Get-AzWvdSessionHost returns Status of "Shutdown" instead of "Unavailable" when VM's are powered off

%3CLINGO-SUB%20id%3D%22lingo-sub-1880518%22%20slang%3D%22en-US%22%3EGet-AzWvdSessionHost%20returns%20Status%20of%20%22Shutdown%22%20instead%20of%20%22Unavailable%22%20when%20VM's%20are%20powered%20off%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1880518%22%20slang%3D%22en-US%22%3E%3CP%3EWhy%20do%20Session%20Host%20VM's%20show%20the%20status%20of%20%22Shutdown%22%20when%20they%20are%20powered%20off%20instead%20of%20%22Unavailable%22%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20been%20successfully%20utilizing%20an%20auto-scaling%20script%20that%20powers%20on%2Foff%20VM's%20based%20on%20user%20demand.%20Until%20recently%2C%20all%20my%20VM's%20in%20my%20host%20pools%20show%20as%20status%20%22Unavailable%22%20when%20they%20are%20powered%20off%20and%20the%20scaling%20script%20looks%20for%20this%20and%20starts%20them%20when%20needed.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20just%20added%20some%20additional%20VM's%20to%20my%20existing%20VM's%20in%20two%20of%20my%20Host%20Pools%20and%20now%20when%20I%20shut%20these%20VM's%20down%2C%20they%20show%20a%20status%20of%20%22Shutdown%22%20and%20so%20the%20scaling%20script%20cannot%20start%20them.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20tried%20manually%20removing%20the%20new%20VM%E2%80%99s%20from%20the%20Host%20Pool%20and%20re-installing%20the%20Agent%20%26amp%3B%20BootLoader%2C%20but%20still%20no%20joy.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20status%20of%20%E2%80%9CShutdown%E2%80%9D%20kind%20of%20makes%20more%20sense%20than%20%E2%80%9CUnavailable%E2%80%9D%2C%20so%20I%20wondered%20if%20there%20has%20been%20a%20change%20in%20the%20way%20the%20VM%E2%80%99s%20agent%20reports%20it%E2%80%99s%20status%20to%20WVD%3F%20If%20so%2C%20this%20would%20break%20the%20scaling%20script%20and%20it%20would%20need%20updating%20to%20suit%2C%20but%20I%20don%E2%80%99t%20see%20that%20this%20can%20be%20the%20case%2C%20as%20my%20original%20VM%E2%80%99s%20in%20the%20Host%20Pool%20are%20running%20the%20same%20latest%20agent%20version%20and%20show%20a%20status%20of%20%E2%80%9CUnavailable%E2%80%9D%20when%20they%20are%20powered%20off.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20-%20what%20is%20this%20%22Shutdown%22%20status%20all%20about%20and%20how%20do%20I%20get%20these%20new%20VM's%20to%20show%20as%20%22Unavailable%22%20when%20they%20are%20powered%20off%20so%20that%20my%20scaling%20script%20will%20work%20again%3F%3C%2FP%3E%3CP%3EHave%20you%20or%20anyone%20else%20seen%20this%2C%20or%20have%20any%20advice%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1883122%22%20slang%3D%22en-US%22%3ERe%3A%20Get-AzWvdSessionHost%20returns%20Status%20of%20%22Shutdown%22%20instead%20of%20%22Unavailable%22%20w%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1883122%22%20slang%3D%22en-US%22%3E%3CP%3EI've%20also%20noticed%20something%20similar%20in%20the%20last%20week%20when%20I%20added%20a%20vm%20to%20an%20existing%20hostpool%2C%20the%20new%20vm%20has%20a%20shutdown%20state%20not%20the%20regular%20unavailable%20state%20when%20its%20deallocated%20by%20the%20scaling%20script.%3C%2FP%3E%3CP%3EHowever%20I%20added%20yet%20another%20vm%20and%20that%20shows%20the%20regular%20unavailable%20status%20when%20the%20vm%20gets%20deallocated%20by%20the%20scaling%20script.%20Not%20really%20sure%20why%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20my%20case%20the%20scaling%20script%20can%20power%20on%20and%20power%20off%20the%20all%20the%20vms.%3C%2FP%3E%3CP%3EI%20am%20curious%20what%20the%20difference%20is%20between%20the%20'Shutdown'%20status%20and%20'Unavailable'%20status%20as%20there%20is%20no%20detail%20on%20the%20docs%20page%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Frest%2Fapi%2Fdesktopvirtualization%2Fsessionhosts%2Fget%23status%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Frest%2Fapi%2Fdesktopvirtualization%2Fsessionhosts%2Fget%23status%3C%2FA%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPerhaps%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F491899%22%20target%3D%22_blank%22%3E%40Christiaan_Brinkhoff%3C%2FA%3E%26nbsp%3Bor%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F181970%22%20target%3D%22_blank%22%3E%40Dean%20Cefola%3C%2FA%3E%26nbsp%3Bcan%20shed%20some%20light%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1883550%22%20slang%3D%22en-US%22%3ERe%3A%20Get-AzWvdSessionHost%20returns%20Status%20of%20%22Shutdown%22%20instead%20of%20%22Unavailable%22%20w%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1883550%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F17439%22%20target%3D%22_blank%22%3E%40Hussayn%20Visram%3C%2FA%3E%20thanks%20for%20confirmation%20that%20others%20are%20seeing%20this.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20using%20the%20(popular%20%26amp%3B%20useful)%20Travis%20Roberts%20scaling%20script%20(%3CA%20href%3D%22https%3A%2F%2Fwww.ciraltos.com%2Fauto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-arm-edition-with-an-azure-function%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.ciraltos.com%2Fauto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-arm-edition-with-an-azure-function%2F%3C%2FA%3E)%20which%20checks%20for%20hosts%20in%20the%20%22Unavailable%22%20state%20to%20start%2C%20so%20the%20new%20hosts%20being%20in%20%22Shutdown%22%20state%20breaks%20the%20script.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20could%20probably%20modify%20the%20script%2C%20but%20I%20wanted%20to%20understand%20what%20this%20(new%3F)%20%22Shutdown%22%20state%20was%20all%20about%20first%20as%20my%20old%20hosts%20are%20all%20still%20showing%20state%20%22Unavailable%22%20even%20when%20running%20the%20same%20latest%20agent%20version%20as%20the%20newly%20added%20VM's.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20would%20very%20much%20appreciate%20some%20light%20shedding%20from%26nbsp%3B%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F491899%22%20target%3D%22_blank%22%3E%40Christiaan_Brinkhoff%3C%2FA%3E%26nbsp%3Bor%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F181970%22%20target%3D%22_blank%22%3E%40Dean%20Cefola%3C%2FA%3E%20if%20they%20knew%20what%20this%20was%20about%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1885607%22%20slang%3D%22en-US%22%3ERe%3A%20Get-AzWvdSessionHost%20returns%20Status%20of%20%22Shutdown%22%20instead%20of%20%22Unavailable%22%20w%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1885607%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F673841%22%20target%3D%22_blank%22%3E%40garymansell%3C%2FA%3E%2C%20the%20scaling%20script%20I%20used%20was%20the%20one%20they%20have%20in%20the%20wvd%20docs%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fvirtual-desktop%2Fset-up-scaling-script%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fvirtual-desktop%2Fset-up-scaling-script%3C%2FA%3E%3C%2FP%3E%3CP%3EThe%20logic%20is%20a%20bit%20differnet%20from%20the%20one%20you%20mentioned%2C%20both%20are%20really%20good.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20takes%20a%20bit%20of%20time%20to%20setup%20(or%20via%20ps%20script%20which%20I%20ended%20up%20doing%20as%20part%20of%20my%20wvd%20deploymet)%20but%20worth%20it%20to%20realise%20the%20cost%20savings.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20overview%20video%20really%20helped%20to%20understand%20whats%20going%20on%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D4zDazJsa2Zk%26amp%3Bt%3D4s%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D4zDazJsa2Zk%26amp%3Bt%3D4s%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAdditionally%2C%20I%20built%20a%20new%20environment%20today%20with%207%20vm%20as%20personal%20desktops%2C%20all%20the%20vms%20show%20Shutdown%20state%20when%20they%20are%20deallocated.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

Why do Session Host VM's show the status of "Shutdown" when they are powered off instead of "Unavailable"?

 

I have been successfully utilizing an auto-scaling script that powers on/off VM's based on user demand. Until recently, all my VM's in my host pools show as status "Unavailable" when they are powered off and the scaling script looks for this and starts them when needed.

 

I have just added some additional VM's to my existing VM's in two of my Host Pools and now when I shut these VM's down, they show a status of "Shutdown" and so the scaling script cannot start them.

 

I have tried manually removing the new VM’s from the Host Pool and re-installing the Agent & BootLoader, but still no joy.

 

The status of “Shutdown” kind of makes more sense than “Unavailable”, so I wondered if there has been a change in the way the VM’s agent reports it’s status to WVD? If so, this would break the scaling script and it would need updating to suit, but I don’t see that this can be the case, as my original VM’s in the Host Pool are running the same latest agent version and show a status of “Unavailable” when they are powered off.

 

So - what is this "Shutdown" status all about and how do I get these new VM's to show as "Unavailable" when they are powered off so that my scaling script will work again?

Have you or anyone else seen this, or have any advice?

7 Replies

I've also noticed something similar in the last week when I added a vm to an existing hostpool, the new vm has a shutdown state not the regular unavailable state when its deallocated by the scaling script.

However I added yet another vm and that shows the regular unavailable status when the vm gets deallocated by the scaling script. Not really sure why

 

 

In my case the scaling script can power on and power off the all the vms.

I am curious what the difference is between the 'Shutdown' status and 'Unavailable' status as there is no detail on the docs page https://docs.microsoft.com/en-us/rest/api/desktopvirtualization/sessionhosts/get#status.

 

Perhaps @Christiaan_Brinkhoff or @Dean Cefola can shed some light?

Hi @Hussayn Visram thanks for confirmation that others are seeing this.

 

I am using the (popular & useful) Travis Roberts scaling script (https://www.ciraltos.com/auto-start-and-stop-session-hosts-in-windows-virtual-desktop-spring-update-...) which checks for hosts in the "Unavailable" state to start, so the new hosts being in "Shutdown" state breaks the script.

 

I could probably modify the script, but I wanted to understand what this (new?) "Shutdown" state was all about first as my old hosts are all still showing state "Unavailable" even when running the same latest agent version as the newly added VM's.

 

I would very much appreciate some light shedding from  @Christiaan_Brinkhoff or @Dean Cefola if they knew what this was about?

Hi @garymansell, the scaling script I used was the one they have in the wvd docs

https://docs.microsoft.com/en-us/azure/virtual-desktop/set-up-scaling-script

The logic is a bit differnet from the one you mentioned, both are really good.

 

It takes a bit of time to setup (or via ps script which I ended up doing as part of my wvd deploymet) but worth it to realise the cost savings.

 

This overview video really helped to understand whats going on

https://www.youtube.com/watch?v=4zDazJsa2Zk&t=4s

 

Additionally, I built a new environment today with 7 vm as personal desktops, all the vms show Shutdown state when they are deallocated.

Windows Virtual Desktop Optimizations will improve WVD density and logon times.This code was developed by "The Virtual Desktop Team" formally known as TheVDI...
best response confirmed by garymansell (Contributor)
Solution

@garymansell I modified the script to include the status of "Unavailable" and "Shutdown" to include VM's in the start function.  Testing shows it's now starting VM's in either state.

@Travis RobertsThis is excellent news - thanks for your speedy resolution. I made the same change myself last week and confirm that it works.

 

If anyone from the WVD Product Team is on here, though, it would be nice to understand why the change in Status for powered off machines? Is this a permanent change, will we no longer see VM's as "Unavailable"? If both states are still possible - what exactly do they mean>

 

Might be nice to add some descriptions to the online doc's too...

@Travis Roberts  Thanks for posting the script and its helpful, however I am getting the below error

: Host pool not set to Depth-First load balancing. This script requires Depth-First load balancing to execute
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException

 

I have set the host pool to depth first and using Get-AzWvdHostPool I can see the loadbalance type is set to Depth First

@VenkataKrishnamurti Can you verify you are using the WVDARM_ScaleHostPoolVMs.ps1 script with the newer, Spring update of WVD?  Based on that error, you may be using the older version for the WVD Clasic.

Thanks