キーの組み合わせの構成を削除する

サポートされているエディション
✅ IoT Enterprise LTSC
✅ IoT Enterprise
✅ Enterprise LTSC
✅ Enterprise
✅ Education

次のサンプル Windows PowerShell スクリプトは、キーボード フィルターの Windows Management Instrumentation (WMI) プロバイダーを使用して、カスタム ブロック ルール構成を削除する 2 つの関数を作成します。 ルールを削除すると、その構成が削除されますが、別のアクティブなルールが同じ物理入力をブロックする可能性があります。

最初の関数 Remove-Custom-Key は、カスタム キーのブロック規則を削除します。

2 番目の関数 Remove-Scancode は、スキャン コード ブロック ルールを削除します。

定義済みのキー ブロック ルールを削除することはできませんが、 Enabled プロパティを 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 スクリプトのサンプル

キーボード フィルター WMI プロバイダー リファレンス

キーボード フィルター