Skip to content

Instantly share code, notes, and snippets.

@supermarsx
Created April 15, 2026 17:19
Show Gist options
  • Select an option

  • Save supermarsx/6066d6e9dde5bc35b1f996033fd59a37 to your computer and use it in GitHub Desktop.

Select an option

Save supermarsx/6066d6e9dde5bc35b1f996033fd59a37 to your computer and use it in GitHub Desktop.
Reset RDS 120-Day Grace Period (Windows Server 2022)

Reset the RDS 120-Day Grace Period (Windows Server 2016/2019/2022)

Scope – Lab, PoC, break-fix.
Not a licensing substitute. Buy & install CALs before production rollout.


0. Check how many days you have left

(Get-CimInstance -Namespace root/CIMV2/TerminalServices `
  -Class Win32_TerminalServiceSetting).GetGracePeriodDays().DaysLeft

1. One-liners to wipe the GracePeriod key

Scenario Command
Local box (SYSTEM) psexec -s -i reg delete "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\RCM\GracePeriod" /f
Local box (explicit \localhost) psexec \\localhost -s -i reg delete "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\RCM\GracePeriod" /f
Remote host psexec \\SRV-RDS01 -u DOMAIN\Admin -p **** -s -i reg delete "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\RCM\GracePeriod" /f

What the command does: Runs reg delete as NT AUTHORITY\SYSTEM, removing the binary value that stores the grace-period timer.


2. Bounce the service (or reboot)

Restart-Service TermService -Force      # faster  
#—or—  
Restart-Computer -Force                 # safer if other RDS pieces are mis-behaving

3. Confirm you’re back to 120 days

(Get-CimInstance -Namespace root/CIMV2/TerminalServices `
  -Class Win32_TerminalServiceSetting).GetGracePeriodDays().DaysLeft
#   →  ~120

4. (Optional) Script the whole thing

iex "& { iwr -useb 'https://gist.githubusercontent.com/.../reset-rds-lab.ps1' }"

(Replace with your own hosted script containing the above steps.)


5. Proper long-term fix

  1. Install-WindowsFeature RDS-Licensing -IncludeManagementTools

  2. Activate the license server in Remote Desktop Licensing Manager

  3. Install RDS CALs

  4. On each Session Host:

    (Get-WmiObject -Namespace root\cimv2\TerminalServices `
      -Class Win32_TerminalServiceSetting).SetSpecifiedLicenseServerList("RDS-LIC01.domain.local")
    (Get-WmiObject -Namespace root\cimv2\TerminalServices `
      -Class Win32_TerminalServiceSetting).ChangeMode(4)  # 4 = Per User, 2 = Per Device

References

  • StarWind blog – “Reset 120-Day RDS Grace Period on Windows Server 2022”
  • GetGracePeriodDays method (WMI) – Microsoft Docs
  • WMIC is deprecated – use CIM / PowerShell instead
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment