We can use the following commands
Get-WmiObject Win32_TSLicenseKeyPack|Select KeyPackId, ProductVersion, TotalLicenses, TypeAndModel|Format-List
Invoke-WmiMethod -Class Win32_TSLicenseKeyPack -Name RemoveLicensesWithIdCount -ArgumentList <Keypack>,<NumberofLicensesToRemove>
For Example, if we had 14 RDS cals, and wanted to reduce them to 12:
PS C:\Windows\system32> Get-WmiObject Win32_TSLicenseKeyPack|Select KeyPackId, ProductVersion, TotalLicenses, TypeAndModel|Format-List
KeyPackId : 2
ProductVersion : Windows 2000 Server
TotalLicenses : 4294967295
TypeAndModel : Built-in TS Per Device CAL
KeyPackId : 3
ProductVersion : Windows Server 2019
TotalLicenses : 14
TypeAndModel : RDS Per User CAL
You can see KeyPackId 3 has the RDS cals we want to reduce, we would use the command:
Invoke-WmiMethod -Class Win32_TSLicenseKeyPack -Name RemoveLicensesWithIdCount -ArgumentList 3,2
This would reduce Keypack 3 by 2 licenses, bringing it to a total of 12.