You can use the Windows Server Manager GUI or PowerShell:

Server Manager GUI: DO NOT ALLOW NEW CONNECTIONS

  1. put-session-host-into-maintenance-mode-do-not-allow-new-connections-Windows-Update-error-0x8024416-Server-2016-RDSLaunch Server Manager
  2. Click REMOTE DESKTOP SERVICES
  3. Click on one of your COLLECTIONS (top left)
  4. Right click on the server in question and select DO NOT ALLOW NEW CONNECTIONS
  5. Wait for the ALLOW NEW CONNECTIONS field to change to False
  6. Run Windows Update on the server in question

When the updates are done and the server is rebooted, just right click on the same server and select ALLOW NEW CONNECTIONS

PowerShell: DO NOT ALLOW NEW CONNECTIONS

Modify the obvious text below to fit your needs.

Set-RDSessionHost -SessionHost "rdsh.contoso.com" -NewConnectionAllowed $True -ConnectionBroker "rdcb.contoso.com"

This was taken from THIS Microsoft article.

If you have multiple RDS Session Hosts and you want to script the DO NOT ALLOW or ALLOW NEW CONNECTIONS use this script.

foreach
($HostToEnable in
(get-rdsessionhost -collectionname WebOrderFarm |
where {$_.NewConnectionAllowed -ne "Yes"}
)
)
{
$HostToEnable
set-RDSessionHost $HostToEnable.SessionHost -NewConnectionAllowed "YES"
}

This was taken from THIS TechNet support page.