Remove key combination configurations

Supported Editions
✅ IoT Enterprise LTSC
✅ IoT Enterprise
✅ Enterprise LTSC
✅ Enterprise
✅ Education

The following sample Windows PowerShell script uses the Windows Management Instrumentation (WMI) providers for Keyboard Filter to create two functions that remove custom blocking-rule configurations. Removing a rule deletes that configuration, but another active rule might still block the same physical input.

The first function, Remove-Custom-Key, removes custom-key blocking rules.

The second function, Remove-Scancode, removes scan-code blocking rules.

You can't remove predefined-key blocking rules, but you can deactivate them by setting their Enabled property to 0.

Remove-rules.ps1

#
# Copyright (C) Microsoft. All rights reserved.
#

<#
.Synopsis
    This script uses the built-in WMI providers to remove Keyboard Filter blocking rules. WEKF_PredefinedKey rules can't be removed.
.Parameter ComputerName
    Optional parameter to specify the remote computer that this script should
    manage.  If not specified, the script will execute all WMI operations
    locally.
#>

param(
    [string] $ComputerName
)

$CommonParams = @{"namespace"="root\standardcimv2\embedded"}
$CommonParams += $PSBoundParameters

function Remove-Custom-Key($Id) {
    <#
    .Synopsis
        Remove a WEKF_CustomKey blocking rule.
    .Description
        Enumerate all WEKF_CustomKey instances. When an instance has an Id that
        matches $Id, delete it.
    .Example
        Remove-Custom-Key "Ctrl+V"

        Removes the WEKF_CustomKey blocking rule for Ctrl+V.
#>

    $customInstance = Get-WMIObject -class WEKF_CustomKey @CommonParams |
        where {$_.Id -eq $Id}

    if ($customInstance) {
        $customInstance.Delete();
        "Removed custom-key blocking rule for $Id.";
    } else {
        "Custom-key blocking rule for $Id does not exist.";
    }
}

function Remove-Scancode($Modifiers, [int]$Code) {
    <#
    .Synopsis
        Remove a WEKF_Scancode blocking rule.
    .Description
        Enumerate all WEKF_Scancode instances. When an instance has matching
        Modifiers and Scancode values, delete it.
    .Example
        Remove-Scancode "Ctrl" 37

        Removes the WEKF_Scancode blocking rule with Modifiers="Ctrl" and
        Scancode=37.
#>

    $scancodeInstance = Get-WMIObject -class WEKF_Scancode @CommonParams |
        where {($_.Modifiers -eq $Modifiers) -and ($_.Scancode -eq $Code)}

    if ($scancodeInstance) {
        $scancodeInstance.Delete();
        "Removed scan-code blocking rule for $Modifiers+$Code";
    } else {
        "Scan-code blocking rule for $Modifiers+$Code does not exist.";
    }
}

# Some example uses of the functions defined above.
Remove-Custom-Key "Ctrl+V"
Remove-Custom-Key "Numpad0"
Remove-Custom-Key "Shift+Numpad1"
Remove-Custom-Key "Shift+5"
Remove-Scancode "Ctrl" 37

Windows PowerShell script samples for keyboard filter

Keyboard filter WMI provider reference

Keyboard filter