Skip to content

Instantly share code, notes, and snippets.

@thenikk
Created November 28, 2023 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thenikk/a20b0903501be87ddcbf3a37b7e612a5 to your computer and use it in GitHub Desktop.
Save thenikk/a20b0903501be87ddcbf3a37b7e612a5 to your computer and use it in GitHub Desktop.
$registryPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations"
$registryName = "DWMFRAMEINTERVAL"
$desiredValue = 15
if (Test-Path -Path $registryPath) {
$keyValue = Get-ItemProperty -Path $registryPath -Name $registryName -ErrorAction SilentlyContinue
if ($keyValue -ne $null -and $keyValue.$registryName -eq $desiredValue) {
Write-Output "Registry key '$registryName' exists with value $($keyValue.$registryName)"
exit 0
}
elseif ($keyValue -ne $null) {
Write-Output "Registry key '$registryName' exists but has a different value: $($keyValue.$registryName)"
exit 1
}
else {
Write-Output "Registry key '$registryName' exists but has no value set."
exit 1
}
}
else {
Write-Output "Registry key '$registryPath' does not exist."
exit 1
}
$registryPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations"
$registryName = "DWMFRAMEINTERVAL"
$desiredValue = 15
# Check if the registry path exists, and if not, create it
if (-not (Test-Path -Path $registryPath)) {
New-Item -Path $registryPath -Force
}
# Set the registry key value with the desired decimal value (no need to specify type)
Set-ItemProperty -Path $registryPath -Name $registryName -Value $desiredValue
Write-Output "Registry key '$registryName' has been set to decimal value $desiredValue."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment