Microsoft Secure Tech Accelerator
Apr 03 2024, 07:00 AM - 11:00 AM (PDT)
Microsoft Tech Community
Manage Remote Desktop Licensing by using Windows PowerShell
Published Sep 07 2018 07:29 PM 10.3K Views
First published on CloudBlogs on Apr, 07 2010
[Aug. 2010: Updated instructions for starting PowerShell in the RDS context] In Windows Server® 2008 R2, we introduced the Remote Desktop Services Provider for Windows PowerShell™ . This post gives examples of how you can use this new feature to manage Remote Desktop Licensing (RD Licensing). This post assumes that you have a basic understanding of Windows PowerShell. As you might already know, Windows PowerShell provides an easy scripting interface for performing administrative tasks. You can write Windows PowerShell scripts to automate the setup deployment per your requirements. Prerequisites: · Install the required Remote Desktop Services feature (that is, Remote Desktop Licensing for Example 1 and Remote Desktop Session Host for Example 2). · Start the Windows PowerShell command window and switch to RDS context:
  1. Click Start, click All Programs, and then click Administrative Tools.
  2. Right-click Windows PowerShell Modules, and then click Run as Administrator.
  3. In the PowerShell command window, type the following:  cd RDS:
After you do this, you will see a Windows PowerShell window with the prompt set to the RDS drive. Following are two examples for configuring a server with Windows PowerShell: Note: When using Powershell commands, make sure that you execute them from the correct path. First cd to the correct directory before executing the command. 1. On the Remote Desktop license server: a. Activate the license server using the Automatic Connection method with the following command: PS RDS:LicenseServer> Set-Item .ActivationStatus -Value 1 -ConnectionMethod AUTO -Reason [Reason] where [Reason] specifies the reason for activation of the license server. It has 6 possible values: 0 - The server was redeployed 1 - The certificate was corrupt 2 - The private key was compromised 3 - The activation key expired 4 - The server was upgraded 5 - The server is being activated for the first time b. Install the Select License Key Pack by using the following command: PS RDS:LicenseServerLicenseKeyPacks> New-Item -path RDS:LicenseServerLicenseKeyPacks -InstallOption INSTALL -ConnectionMethod AUTO -LicenseType AGREEMENT -AGREEMENTTYPE 0 -AGREEMENTNUMBER [AgreementNumber] -PRODUCTVERSION [ProductVersion] -PRODUCTTYPE [ProductType] -LICENSECOUNT [LicenseCount]
where [AgreementNumber] refers to the Agreement Number for the licenses, [ProductVersion] refers to the version of the licenses. It has three possible values: 0 - Windows 2000 Server 1 - Windows Server 2003 2 - Windows Server 2008 or Windows Server 2008 R2 [ProductType] refers to the type of license. It has four possible values: 0 - for Per Device 1 - for Per User 4 - for VDI Standard 5 - for VDI Premium, and [LicenseCount] refers to the number of licenses that you want to install. c. Add the license server to the Terminal Server License Servers group on the domain controller by using the following command: PS RDS:LicenseServer> Set-Item .LSinTSLSGroup -Value 1 Note: To run this command, you need to have Enterprise Admin privileges. d. Query to see if the license server is registered in Service Connection Point (SCP) by using the following command: PS RDS:LicenseServer> Get-Item .SCPRegistrationStatus This command will show the current value, permissible values, and the permissible operations for the property. If the value of ‘SCPRegistrationStatus’ property is set to 1, it means that the license server is already registered in SCP. e. Generate the Per User license usage report by using the following command: PS RDS:LicenseServerIssuedLicensesPerUserLicenseReports> New-Item -Name [NameOfReport] -Scope [Scope] where [NameOfReport] is the name with which you want to refer to the report, and [Scope] represents the scope of the report. It can have three values: DOM - Generate a report for the entire domain ALLTRUSTEDDOM - Generate a report for all trusted domains OU - Generate a report for the organizational unit (OU) 2. On the Remote Desktop Session Host (RD Session Host) server: a. Specify the licensing mode on the RD Session Host server using the following command: PS RDS:RDSConfigurationLicensingSettings> Set-Item .LicensingType -Value [Type] where, the possible values of [Type] are: 2 - Per Device 4 - Per User b. In the Specified License Server list, add the license server name by using the following command: PS RDS:RDSConfigurationLicensingSettingsSpecifiedLicenseServers> New-Item -Name [LSName] where [LSName] refers to the name of the license server.

For more information about licensing and Windows PowerShell, use these commands: cd , dir , and Get-Help .

1 Comment
Copper Contributor

Hi

This does not work with Windows Server 2016. I have tested the possible values ​​for [ProductVersion] 0 to 4, but none of them allows you to install a Windows 2016 license package. Could you help me? Thanks.

Version history
Last update:
‎Sep 07 2018 07:29 PM