Reset time cho remote desktop

# Remove-RDSTimebomb.ps1
# Remove registry value start with "L$RTMTIMEBOMB" in key GracePeriod
# Require: run as Administrator

$ErrorActionPreference = 'SilentlyContinue'
$path = "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\RCM\GracePeriod"
if (Test-Path $path) {
    $values = (Get-Item $path).GetValueNames() | Where-Object { $_ -like "L$RTMTIMEBOMB*" }
    foreach ($v in $values) {
        try {
            Remove-ItemProperty -Path $path -Name $v -Force
            Write-Output ("{0} - Removed: {1} in {2}" -f (Get-Date -Format 'yyyy-MM-dd HH:mm:ss'), $v, $path)
        } catch {
            Write-Output ("{0} - Error {1}: {2}" -f (Get-Date -Format 'yyyy-MM-dd HH:mm:ss'), $v, ${_}.Exception.Message)
        }
    }
} else {
    Write-Output ("{0} - Not found key GracePeriod." -f (Get-Date -Format 'yyyy-MM-dd HH:mm:ss'))
}
Write-Output "Success."

No comments:

Post a Comment

Reset time cho remote desktop

# Remove-RDSTimebomb.ps1 # Remove registry value start with "L$RTMTIMEBOMB" in key GracePeriod # Require: run as Administrator $Er...