Having fully installed Remote Desktop Services (RDS) on a server with the RD Connection Broker and RDS licensing set per user and everything is working with a valid license.
After some time you notice a popup when you connect saying,
Remote Desktop licensing mode is not configured
Remote Desktop Services will stop working in 104 days. On the RD Connection Broker server, use Server Manager to specify the Remote Desktop licensing mode and the license server.
When you open the RD Licensing Diagnoser, you will be prompted with an error saying, The licensing mode for the Remote Desktop Session Host server is not configured.
From the Server Manager under Configure the Deployment and RD licensing, all seem to be configured well.
Open a PowerShell as Administrator on the server and run the following command
$obj = gwmi -namespace "Root/CIMV2/TerminalServices" Win32_TerminalServiceSetting
This will show a parameter called SpecifiedLicenseServerList which would be empty as below.
To populate the parameter, use the following command
$obj.SetSpecifiedLicenseServerList("<full fqdn server name>")
After this is done, the RD Licensing Diagnoser parameter should not report any errors. It is suggested to restart the server after this change.
Alternatively, one could do this with registry with the following PowerShell script
# Specify the RDS licensing type: 2 - Per Device CAL, 4 - Per User CAL
$RDSCALMode = 4
$RDSlicServer = "<server full fqdn name>"
# Set the server name and type of licensing in the registry
New-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Services\TermService\Parameters\LicenseServers" -Name SpecifiedLicenseServers -Value $RDSlicServer -PropertyType "MultiString"
Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\RCM\Licensing Core\" -Name "LicensingMode" -Value $RDSCALMode