Automatic Scaling of Remote Desktop Session Hosts in Azure Virtual Machines

RDSScaler.ps1 is a sample PowerShell script that can be used as a starting point for developing a solution to automatically scale a Remote Desktop Services (RDS) deployment on Microsoft Azure Infrastructure Services. Version 2.0 uses the Azure Resource Manager PowerShell.

4.4 Star
3,381 times
Add to favorites
E-mail Twitter Digg Facebook
  • Script still updated?
    1 Posts | Last post January 07, 2020
      Is this script being updated anymore or is there a better way to manage the VMs Out of hours?  
      We are running on a 2016 RDS Farm and finding all the Servers are being put into Drain Mode and this not clearing after a reboot. - So at 7am the servers start up but no one can login.
      Would also want the script to only shut the RDS Host down once Active Connections = 0 - Is this possible?
      For those who want to target a specific Collection, I've amended line 281 to read:
      $Collections=Get-RDSessionCollection -ConnectionBroker $ConnectionBrokerFQDN -ErrorAction Stop | Where-Object CollectionName -eq "{Collection Name}"
      And this works (we have 3 Collections running and this only shuts down the VMs in the named collection)
      Thanks :)
  • Running script in Windows 2019 Server?
    1 Posts | Last post October 29, 2019
    • Have anyone try to run this script on Windows Server 2019? I will give it a shot and I am looking if other people were successful to run it?
  • Issues with Multiple Collections on single RD CB Server
    1 Posts | Last post July 30, 2019
    • When we run this script against our RD Connection Broker that has multiple collections, we have an issue with all servers in a single collection being set to drain mode. 
      Details: We have 2 Collections on the RD Connection Broker. Both Collections have 3 RD Host Servers. The RD Host servers in each Collection are each in their own Resource Group, meaning all RD Host Servers for a collection are grouped into a single resource group.
      I set the Config to keep up 2 Servers in off peak mode and run the script against a resource group. All servers in Collection A were put into Drain Mode. All 3 RD Host servers in the collection had a user logged in, so that may have caused an issue as well.
      Can anyone offer suggestions on how to force this script to only focus on a single collection?
  • Fail to Send Message
    1 Posts | Last post November 19, 2018
    • I am getting the below error in after hours mode.
      Current number of running hosts:  xx
      Failed to send message to user with error: Failed to send message. Access was denied.
      Then script stops executing, and no servers are shut down, startup seems to work perfectly.
  • Time zone
    1 Posts | Last post May 15, 2018
    • Looking at this script, it's a bit confusing on time zone. This script actually pulls the time from the local machine which is adjusted for the selected time zone, not UTC as the documentation suggests. Please correct this. 
  • PowerShell is exiting with following error "Failed to retrieve RDS collections: The specified FQDN is not valid"
    2 Posts | Last post May 15, 2018
    • 2/12/2018 8:06:42 AM - [Info] Starting RDS Scale Optimization: Current Date Time is: 02/12/2018 08:06:42
      2/12/2018 8:06:42 AM - [Error] Failed to retrieve RDS collections: The specified FQDN  is not valid.
      Please suggest.
    • You must use a domain account with permissions to manage the RDS Farm. 
  • Drain Mode
    1 Posts | Last post April 20, 2018
    • This Script put all servers in drain mode and shutdown one by one. Could you change this please? Or send me what I need to change?
  • Some minor additions?
    2 Posts | Last post November 04, 2017
    • Is it possible to upgrade the script with an exclusion variable for a collection? Currently the script runs against all collections, i would like to provide the names of the collections that need to be scaled.
      the same with the hosts, would be nice if we can mark a server within the collection as 'excluded' within the count.
    • We noticed some strange behaviour. The script sometimes sets all availabe servers in drain mode and starts trurning servers off until only 4 (our setting) are kept running. But those server will stay in drain mode.
  • Logic
    1 Posts | Last post June 28, 2017
    • Anyone know how the logic works of this script. For example we have 11 session host servers. I told it to leave 3 servers on during off peak hours. I went to server 1 saw someone was logged on, put server to drain, then asked them to log off. Which the user did. They then logged into another server. The script then went to that server and told them to log off yet again. 
      I would have expected the script to enumerate which 3 servers have the most load, set the other to drain. Then proceed to the servers with the least logged in users. then ask them to log off. This way they would get put back on to a server which will stay on?
      At the moment it just goes through each server in turn turning them off 1 by 1. Until it leaves the last 3 on......
  • Azure ARM version?
    2 Posts | Last post September 23, 2016
    • This crashes on line 329 in an Azure ARM environment.
      >>$Deployment=Get-AzureDeployment -ServiceName $CloudServiceName -ErrorAction Stop
      As far as I can see there is no ARM equivalent of the Get-AzureDeployment cmdlet. Does anyone have an alternative? Cheers!
    • Blair,
      Have you tried get-azurermresourcegroupdeployment? I think that's the cmdlet
1 - 10 of 15 Items