WVD Scaling Script: Doesn't Logoff user sessions and stop VMs during off-peak hours

Copper Contributor



We have experienced that during the off-peak hours the scaling script doesn't logoff user sessions and stop VMs when there are active or disconnected sessions. 


Minimum number of running session host threshold is set to 1



  • Script recognize it as off-peak hours but doesn't logoff any user sessions. 

But we have noticed following log not sure if there is any relation.

Number of user sessions is more than 90 % of the max number of sessions allowed with minimum number of running session hosts required (10). Adjusted minimum number of running session hosts required to 2


Any advice or a solution for this ?


Thank You!



Romero Silva


2 Replies

Which scaling solutions are you using? Is the one provided at Microsoft Docs -site?

Have you set parameter LimitSecondsToForceLogOffUser. Think it defaults to zero, but I'm not sure as I have not used this solution in ages. When set to zero, any user logged in will be left untouched.

You could control session limit also with Group Policy at Computer Configuration > Policies > Administrative Templates > Windows Components > Remote Desktop Services > Remote Desktop Session Host > Session Time Limits

I use scaling solution by Travis Roberts found at https://www.ciraltos.com/update-with-breadth-first-auto-scale-session-hosts-in-windows-virtual-deskt...

- Jere

Use gpo to log inactive sessions off and people who haven’t had any activity for a certain amount of time. Works fine