如何重設遠端桌面服務 (RDS) 的 120 天試用期

遠端桌面服務 (RDS) 是 Windows Server 中的一項關鍵功能,可讓使用者遠端存取桌面和應用程式。根據預設,RDS 在要求正確授權之前提供120 天試用期。但試用期一旦到期,除非套用授權,否則使用者無法透過 RDS 連線。

對於測試或暫存環境,你可能需要重設試用期以延長功能。本指南說明如何手動重設 120 天試用期,並提供用於自動化的指令碼。注意:此程序僅應用於非生產環境,且必須遵守 Microsoft 的授權條款。


為什麼要重設 RDS 試用期?

120 天試用期通常用於:

  • 測試和評估遠端桌面服務。
  • 為開發環境搭建暫存設定。
  • 避免在授權過渡期間中斷。

重設試用期不能取代購買授權。對於生產環境,請務必確保遵守 Microsoft 的授權原則。


重設 120 天試用期的逐步指南

重要警告:

重設試用期涉及修改系統檔案和登錄設定。請謹慎操作,並在變更之前備份伺服器。


步驟 1:停止遠端桌面授權服務

  1. 在 Windows Server 上開啟服務。
    • 按Win + R,輸入services.msc,然後按 Enter 鍵。
  2. 找到遠端桌面授權服務。
  3. 以滑鼠右鍵按一下該服務,然後選取停止。

步驟 2:刪除授權寬限期機碼

  1. 開啟登錄編輯程式:
    • 按Win + R,輸入regedit,然後按 Enter 鍵。
  2. 瀏覽至下列登錄路徑:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TermService\Parameters
  3. 找到GracePeriod機碼。
  4. 刪除GracePeriod機碼。注意:
    • 如果系統阻止你刪除該機碼,你可能需要取得該登錄項目的擁有權:
      • 以滑鼠右鍵按一下GracePeriod機碼,選取權限,然後按一下進階。
      • 將擁有權變更為你的使用者帳戶或系統管理員。
      • 授與完全控制權限以刪除該機碼。

步驟 3:重新啟動遠端桌面授權服務

  1. 返回服務。
  2. 找到遠端桌面授權服務。
  3. 以滑鼠右鍵按一下該服務,然後選取啟動。

步驟 4:驗證試用期重設

  1. 開啟遠端桌面授權管理員。
  2. 確認試用期已重設為120 天。
  3. 測試 RDS 連線,確保其正常運作。

使用指令碼自動重設

如果你經常需要為測試環境重設 RDS 試用期,可以使用下列 PowerShell 指令碼自動完成此程序。此指令碼會停止授權服務、刪除 GracePeriod 登錄機碼並重新啟動服務。

重設 120 天試用期的 PowerShell 指令碼

# Stop Remote Desktop Licensing Service
Write-Host "Stopping Remote Desktop Licensing service..." -ForegroundColor Yellow
Stop-Service -Name TermService -Force
Start-Sleep -Seconds 5

# Define the GracePeriod registry path
$GracePeriodPath = "HKLM:\SYSTEM\CurrentControlSet\Services\TermService\Parameters\GracePeriod"

# Check if the GracePeriod key exists
if (Test-Path $GracePeriodPath) {
    Write-Host "GracePeriod key found. Taking ownership..." -ForegroundColor Yellow
    
    # Take ownership of the GracePeriod key
    Invoke-Expression "cmd.exe /c takeown /f $GracePeriodPath /a /r /d y"
    Start-Sleep -Seconds 2

    # Grant full control to the Administrator group
    Invoke-Expression "cmd.exe /c icacls $GracePeriodPath /grant administrators:F /t /c"
    Start-Sleep -Seconds 2

    # Delete the GracePeriod key
    Write-Host "Deleting GracePeriod key..." -ForegroundColor Yellow
    Remove-Item -Path $GracePeriodPath -Recurse -Force
} else {
    Write-Host "GracePeriod key not found. Skipping deletion." -ForegroundColor Green
}

# Restart Remote Desktop Licensing Service
Write-Host "Restarting Remote Desktop Licensing service..." -ForegroundColor Yellow
Start-Service -Name TermService
Start-Sleep -Seconds 5

Write-Host "RDS trial period reset successfully!" -ForegroundColor Green

如何使用指令碼

  1. 以系統管理員身分開啟PowerShell。
  2. 將指令碼複製並貼到 PowerShell 主控台,或將其儲存為.ps1檔案。
  3. 執行指令碼。
  4. 透過存取遠端桌面授權管理員來驗證試用期是否已重設。

重要注意事項

  • 僅供測試:此程序僅適用於非生產環境。對於生產用途,請務必購買並套用適當的 RDS 用戶端存取授權 (CAL)。
  • 合規性:確保遵守 Microsoft 的授權原則。濫用此程序可能違反授權合約。
  • 備份:在變更之前,請務必備份伺服器和登錄,以免意外遺失資料或損毀資料。

疑難排解

如果試用期重設不起作用:

  1. 確保你擁有系統管理權限。
  2. 驗證GracePeriod機碼是否已成功刪除。
  3. 重新啟動伺服器並重新檢查試用期狀態。
  4. 如果指令碼失敗,請依照指南中的步驟手動操作。

結論

對於非生產環境中的測試或暫存使用,重設遠端桌面服務的 120 天試用期可能是有用的解決方案。無論你選擇手動重設試用期還是使用指令碼自動完成此程序,都請確保仔細遵循步驟並遵守授權條款。對於生產環境,請務必使用正確授權的 RDS CAL,以確保服務不中斷並遵守 Microsoft 的原則。

1 thought on “How to Reset the 120-Day Trial Period for Remote Desktop Services (RDS)”

發表留言