Reset grace period - RDS
🪟 Windows POWERSHELLReset licencji testowej RDS
🕒 2026-04-14
📦 Źródło: own
skrypt.ps1
# Włącz przywileje (jeśli nowa sesja PS - wykonaj ponownie)
[TokenPrivilege]::Enable("SeTakeOwnershipPrivilege")
[TokenPrivilege]::Enable("SeRestorePrivilege")
# Użyj SID grupy Administrators (S-1-5-32-544) - działa na każdym języku
$adminSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-544")
$regKey = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey(
"SYSTEM\CurrentControlSet\Control\Terminal Server\RCM\GracePeriod",
[Microsoft.Win32.RegistryKeyPermissionCheck]::ReadWriteSubTree,
[System.Security.AccessControl.RegistryRights]::TakeOwnership
)
$acl = $regKey.GetAccessControl()
$acl.SetOwner($adminSID)
$regKey.SetAccessControl($acl)
Write-Host "Własność przejęta." -ForegroundColor Cyan
# Nadaj pełną kontrolę
$regKey2 = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey(
"SYSTEM\CurrentControlSet\Control\Terminal Server\RCM\GracePeriod",
[Microsoft.Win32.RegistryKeyPermissionCheck]::ReadWriteSubTree,
[System.Security.AccessControl.RegistryRights]::ChangePermissions
)
$acl2 = $regKey2.GetAccessControl()
$rule = New-Object System.Security.AccessControl.RegistryAccessRule(
$adminSID,
"FullControl",
"ContainerInherit,ObjectInherit",
"None",
"Allow"
)
$acl2.SetAccessRule($rule)
$regKey2.SetAccessControl($acl2)
Write-Host "Uprawnienia nadane." -ForegroundColor Cyan
# Usuń wpis L$RTMTIMEBOMB
$key = "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\RCM\GracePeriod"
Remove-ItemProperty -Path $key -Name * -Force
Write-Host "Grace period zresetowany. Zaplanuj restart SAPP01." -ForegroundColor Green