支援的
✅版本IoT 企業版 LTSC、IoT 企業版
✅、企業版 LTSC✅
、企業版、教育版
✅
✅
下列範例Windows PowerShell指令碼使用 Windows Management Instrumentation (鍵盤篩選器的 WMI) 提供者,建立兩個移除自訂封鎖規則設定的函式。 移除規則會刪除該組態,但另一個使用中規則可能仍會封鎖相同的實體輸入。
第一個函數 Remove-Custom-Key 會移除自訂金鑰封鎖規則。
第二個函數 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