Lock Screen:
REG ADD "HKEY_USERS\.DEFAULT\Control Panel\Keyboard" /v "InitialKeyboardIndicators" /t REG_SZ /d "2147483650" /f
Current User:
REG ADD "HKCU\Control Panel\Keyboard" /v "InitialKeyboardIndicators" /t REG_SZ /d 2 /f
New Users:
REG LOAD HKLM\hive c:\users\default\ntuser.dat REG ADD "HKLM\Hive\Control Panel\Keyboard" /v "InitialKeyboardIndicators" /t REG_SZ /d "2147483650" /f REG UNLOAD HKLM\hive
Detection:
$regKeyPath = "Registry::HKU\.DEFAULT\Control Panel\Keyboard"
$expectedValue = "2"
if (Test-Path $regKeyPath) {
$currentValue = (Get-ItemProperty -Path $regKeyPath -Name InitialKeyboardIndicators).InitialKeyboardIndicators
if ($currentValue -eq $expectedValue) {
Write-Output "Compliant: InitialKeyboardIndicators registry value is set to $expectedValue"
exit 0
} else {
Write-Output "Non-compliant: InitialKeyboardIndicators registry value is not set to $expectedValue"
exit 1
}
} else {
Write-Output "Non-compliant: InitialKeyboardIndicators registry key does not exist"
exit 1
}
Remediation:
$regKeyPath = "Registry::HKU\.DEFAULT\Control Panel\Keyboard"
$valueToSet = "2"
Set-ItemProperty -Path $regKeyPath -Name "InitialKeyboardIndicators" -Value $valueToSet
# Check if the registry value was set successfully
if ($?) {
Write-Output "Remediated: InitialKeyboardIndicators registry value set to $valueToSet"
exit 0
} else {
Write-Output "Failed to remediate: Unable to set InitialKeyboardIndicators registry value"
exit 1
}
Detection:
$regKeyPath = "Registry::HKCU\Control Panel\Keyboard"
$expectedValue = "2"
if (Test-Path $regKeyPath) {
$currentValue = (Get-ItemProperty -Path $regKeyPath -Name InitialKeyboardIndicators).InitialKeyboardIndicators
if ($currentValue -eq $expectedValue) {
Write-Output "Compliant: InitialKeyboardIndicators registry value is set to $expectedValue"
exit 0
} else {
Write-Output "Non-compliant: InitialKeyboardIndicators registry value is not set to $expectedValue"
exit 1
}
} else {
Write-Output "Non-compliant: InitialKeyboardIndicators registry key does not exist"
exit 1
}
Remediation:
$regKeyPath = "Registry::HKCU\Control Panel\Keyboard"
$valueToSet = "2"
Set-ItemProperty -Path $regKeyPath -Name "InitialKeyboardIndicators" -Value $valueToSet
# Check if the registry value was set successfully
if ($?) {
Write-Output "Remediated: InitialKeyboardIndicators registry value set to $valueToSet"
exit 0
} else {
Write-Output "Failed to remediate: Unable to set InitialKeyboardIndicators registry value"
exit 1
}
Oneliner:
reg add "HKU\.DEFAULT\Control Panel\Keyboard" /v InitialKeyboardIndicators /t REG_SZ /d 2147483650 /f & reg add "HKEY_USERS\.DEFAULT\Control Panel\Keyboard" /v InitialKeyboardIndicators /t REG_SZ /d 2147483650 /f & for /f "tokens=1" %i in ('reg query HKU ^| findstr S-1-5-21') do reg add "%i\Control Panel\Keyboard" /v InitialKeyboardIndicators /t REG_SZ /d 2147483650 /f 2>nul