Remove RDS CALs from RDS Server

Background

There are many circumstances where you will need to remove a RDS CALs from an RDS Server, or in some cases you want to rebuild the entire RD licensing database.  Microsoft allows you to remove an individual CAL license pack using powershell, or rebuild the entire database.  However, if neither of those work, it’s quite easy to manually rebuild the RD licensing database.  I’ve included directions for all 3 methods below, and have tested this on Windows Server 2008, 2008R2, 2012, 2012R2, and 2016.

Remove An Individual RDS CAL License Pack Using Powershell (User or Device CAL)

  • Open powershell elevated as an administrator
  • Type the following command to list the RDS Licenses and note the KeyPackID
    • Alternatively, open RD Licensing Manager and note the Keypack ID
Get-WmiObject Win32_TSLicenseKeyPack
  • Run the below command to remove the licenses pack from your RD Server
    • Replace KEYPACKID with the number you obtained above
wmic /namespace:\\root\CIMV2 PATH Win32_TSLicenseKeyPack CALL UninstallLicenseKeyPackWithId KEYPACKID

 

Rebuild the RD Licensing Database

Microsoft provides directions on how to do this automatically, via a web browser, or via the phone:

https://technet.microsoft.com/en-us/library/dd851428.aspx

 

Manually Rebuild the Licensing Database (Guaranteed to Work if the Previous 2 methods Fail)

  • Make sure you have documentation of your MS License agreement that includes Authorization number, License number, License type (User/Device CAL), and Quantity before proceeding
  • Stop the Remote Desktop Licensing service

Stop Remote Desktop Licensing Service

  • Rename C:\Windows\System32\lserver\TLSLic.edb to C:\Windows\System32\lserver\TLSLic.old
  • Start the Remote Desktop Licensing service
  • All licenses will now be cleared out of RD Licensing Manager, and you’ll need to re-install the licenses you want to add back in

16 comments

1 pings

Skip to comment form

    • James Mitchell on November 8, 2017 at 3:24 pm

    Forgive me for asking, but in the second command line you use the word “namespace” without any explanation and then, my personal favorite “Replace KEYPACKID with the number you obtained from above”…
    The command you have there doesn’t have the word KEYPACKID!!!

    Help please? Perhaps a little clarity for the newbie?!?!

    1. It’s just the syntax used for the wmic command, same as using a WMI namespace. If you want to read more details on WMIC, I’d suggest reading about it on MSDN https://msdn.microsoft.com/en-us/library/bb742610.aspx.

      KEYPACKID is the last thing in the command. There’s a little scroll bar because it’s a long command. You can either scroll over or click the “Copy” button which will highlight the full command and tell you to press CTRL + C. You can then paste it into a text editor to better read/manipulate

    • JB on February 23, 2018 at 4:57 pm

    Thanks for this! Needed to remove just that last CAL added and re-add due to an error in listing the number of licenses. I did not want to have to rebuild the db and clear all entries. Worked perfectly

    • Nelson Fernandes on April 24, 2018 at 7:59 am

    Thanks, Rename C:\Windows\System32\lserver\TLSLic.edb to C:\Windows\System32\lserver\TLSLic.old
    Start the Remote Desktop Licensing service
    This work for me but Although I purchased RDS 5 qty license, unable to use. Error showing only two license can be use.

  1. ” However, if neither of those work, it’s quite easy to manually rebuild the RD licensing database”
    I don’t agree, read
    https://www.directionsonmicrosoft.com/secured/2016/10/windows-server-pricing
    – Stefanie

    • Adam S on September 1, 2019 at 11:13 pm

    Hello there,
    This was very helpful, and the instructions worked great on a 2008 R2 server.
    Thank you very much.

    • Ali S on September 6, 2019 at 3:08 pm

    thank you for this post. the guaranteed method of renaming the file worked perfectly for me!

    • TT on November 14, 2019 at 8:52 am

    ran the Powershell command successfully, but i still see license pack in RD License Manager. Does it require any other step

    1. It does not. I would suggest double checking your command for typos & make sure you have the correct KeyPackID in the command. I’ve successfully tested on server 2008, 2012, and 2016. If you are using 2019, I have not tested (they may have changed something but should work)

        • Raul on December 10, 2019 at 11:45 am

        hey I have a question, for error my team reset the server and didn’t migrate de RDS CALs, now they seem to appear activated, do you know any solution? what can I do?

        Thank you

        1. Are they activated on the current/new server or old one? As long as they are active only on the current one, you should be good. Otherwise, just deactivate the old ones using the directions on this page.

    • Tony on December 8, 2019 at 6:49 pm

    Thank you for sharing! Very useful. It helped me. 🙂

    • Maria on April 14, 2020 at 1:31 am

    Thank you for this post. The method worked perfectly for me too, on RDS windows server 2019.

  2. For me it’s not working, when I do the step of deleting the License like so, I got back a value:
    –PS C:\windows\system32> wmic /namespace:\\root\CIMV2 PATH Win32_TSLicenseKeyPack CALL UninstallLicenseKeyPackWithId 4
    Executing (Win32_TSLicenseKeyPack)->UninstallLicenseKeyPackWithId()
    Method execution successful.
    Out Parameters:
    instance of __PARAMETERS
    {
    ReturnValue = 2147508238;
    };

    1. I have not run across this particular issue ever, but you may want to try running it in an elevated command prompt. If that does not work, an alternative is to deactivate the licensing server, uninstall the RD/TS Licensing Role service, reinstall, activate, and install your license pack(s) again. This wipes out the license server database and recreates it

    • Oscar Alvarez on February 14, 2021 at 6:51 pm

    I did it and know says that my key is already activated. Please what can i do? Thanks

Comments have been disabled.