UWF_RegistryFilter

在统一写入筛选器 (UWF) 筛选中添加或删除注册表排除项,并提交注册表更改。

语法

class UWF_RegistryFilter{
    [key, Read] boolean CurrentSession;
    [Read, Write] boolean PersistDomainSecretKey;
    [Read, Write] boolean PersistTSCAL;

    UInt32 AddExclusion(
        string RegistryKey
    );
    UInt32 RemoveExclusion(
        string RegistryKey
    );
    UInt32 FindExclusion(
        [in] string RegistryKey,
        [out] boolean bFound
    );
    UInt32 GetExclusions(
        [out, EmbeddedInstance("UWF_ExcludedRegistryKey")] string ExcludedKeys[]
    );
    UInt32 CommitRegistry(
        [in] string RegistryKey,
        [in] string ValueName
    );
    UInt32 CommitRegistryDeletion(
        string Registrykey,
        string ValueName
    );
};

成员

下表列出了属于此类的方法和属性。

方法 描述
UWF_RegistryFilter.AddExclusion 将注册表项添加到 UWF 的注册表排除列表。
UWF_RegistryFilter.CommitRegistry 提交对指定注册表项和值的更改。
UWF_RegistryFilter.CommitRegistryDeletion 删除指定的注册表项或注册表值并提交删除。
UWF_RegistryFilter.FindExclusion 确定是否将特定注册表项排除在 UWF 筛选之外。
UWF_RegistryFilter.GetExclusions 从受 UWF 保护的系统中检索所有注册表项排除项
UWF_RegistryFilter.RemoveExclusion 从统一写入筛选器 (UWF) 的注册表排除列表中删除注册表项。

属性

属性 数据类型 限定 符 描述
CurrentSession 布尔 [key,read] 指示对象包含其设置的会话。
- 如果当前会话
- 的设置为 True 如果设置用于重启后的下一个会话,则为 False。
PersistDomainSecretKey 布尔 [读取、写入] 指示域机密注册表项是否在注册表排除列表中。 如果注册表项不在排除列表中,则重启后不会保留更改。
- 如果为 True ,则包含在排除列表中
- 否则为 False
PersistTSCAL 布尔 [读取、写入] 指示终端服务器客户端访问许可证 (TSCAL) 注册表项是否在 UWF 注册表排除列表中。 如果注册表项不在排除列表中,则重启后不会保留更改。
- 如果为 True ,则包含在排除列表中
- 否则,设置为 False

备注

添加或删除注册表排除项(包括对 PersistDomainSecretKeyPersistTSCAL 的值的更改)在下次重启(其中启用了 UWF)后生效。

只能将 HKLM 注册表根目录中的注册表项添加到 UWF 注册表排除列表。

还可以使用 UWF_RegistryFilter 从 UWF 筛选中排除域机密注册表项和 TSCAL 注册表项。

示例

以下示例演示如何在 PowerShell 脚本中使用 Windows Management Instrumentation (WMI) 提供程序来管理 UWF 注册表排除项。

PowerShell 脚本创建四个函数,然后演示如何使用它们。

第一个函数 Get-RegistryExclusions 显示当前会话和重启后下一个会话的 UWF 注册表排除列表。

第二个函数 Add-RegistryExclusion 在重启设备后将注册表项添加到 UWF 注册表排除列表。

第三个函数 Remove-RegistryExclusion 在重启设备后从 UWF 排除列表中删除注册表项。

第四个函数 Clear-RegistryExclusions 删除所有 UWF 注册表排除项。 在 UWF 停止筛选排除项之前,必须重启设备。

$COMPUTER = "EMBEDDEDDEVICE"
$NAMESPACE = "root\standardcimv2\embedded"

# Define common parameters

$CommonParams = @{"namespace"=$NAMESPACE; "computer"=$COMPUTER}

function Get-RegistryExclusions() {

# This function lists the UWF registry exclusions, both
# for the current session as well as the next session after a restart.


# Get the UWF_RegistryFilter configuration for the current session

    $currentConfig = Get-WMIObject -class UWF_RegistryFilter @CommonParams |
        where {
            $_.CurrentSession -eq $true
        };

# Get the UWF_RegistryFilter configuration for the next session after a restart

    $nextConfig = Get-WMIObject -class UWF_RegistryFilter @CommonParams |
        where {
            $_.CurrentSession -eq $false
        };

# Display registry exclusions for the current session

    if ($currentConfig) {

        Write-Host ""
        Write-Host "The following registry entries are currently excluded from UWF filtering:";

        $currentExcludedList = $currentConfig.GetExclusions()

        if ($currentExcludedList.ExcludedKeys) {
            foreach ($registryExclusion in $currentExcludedList.ExcludedKeys)  {
                Write-Host "  " $registryExclusion.RegistryKey
            }
        } else {
            Write-Host "  None"
        }
    } else {
        Write-Error "Could not retrieve UWF_RegistryFilter.";
}

# Display registry exclusions for the next session after a restart

    if ($nextConfig) {

        Write-Host ""
        Write-Host "The following registry entries will be excluded from UWF filtering after the next restart:";

        $nextExcludedList = $nextConfig.GetExclusions()

        if ($nextExcludedList.ExcludedKeys) {
            foreach ($registryExclusion in $nextExcludedList.ExcludedKeys)  {
                Write-Host "  " $registryExclusion.RegistryKey
            }
        } else {
            Write-Host "  None"
        }
        Write-Host ""
    }
}

function Add-RegistryExclusion($exclusion) {

# This function adds a new UWF registry exclusion.
# The new registry exclusion takes effect the next time the device is restarted and UWF is enabled.

# $exclusion is the path of the registry exclusion

# Get the UWF_RegistryFilter configuration for the next session after a restart

    $nextConfig = Get-WMIObject -class UWF_RegistryFilter @CommonParams |
        where {
            $_.CurrentSession -eq $false
        };

# Add the exclusion

    if ($nextConfig) {
        $nextConfig.AddExclusion($exclusion) | Out-Null;
        Write-Host "Added exclusion $exclusion.";
    } else {
        Write-Error "Could not retrieve UWF_RegistryFilter";
    }
}

function Remove-RegistryExclusion($exclusion) {

# This function removes a UWF registry exclusion.
# The registry exclusion is removed the next time the device is restarted

# $exclusion is the path of the registry exclusion

# Get the UWF_RegistryFilter configuration for the next session after a restart

    $nextConfig = Get-WMIObject -class UWF_RegistryFilter @CommonParams |
        where {
            $_.CurrentSession -eq $false
        };

# Try to remove the exclusion

    if ($nextConfig) {
        try {
            $nextConfig.RemoveExclusion($exclusion) | Out-Null;
            Write-Host "Removed exclusion $exclusion.";
        } catch {
            Write-Host "Could not remove exclusion $exclusion."
        }
    } else {
        Write-Error "Could not retrieve UWF_RegistryFilter";
    }
}

function Clear-RegistryExclusions() {

# This function removes all UWF registry exclusions
# The registry exclusions are removed the next time the device is restarted

# Get the configuration for the next session

    $nextConfig = Get-WMIObject -class UWF_RegistryFilter @CommonParams |
        where {
            $_.CurrentSession -eq $false
        };

# Remove all registry exclusions

    if ($nextConfig) {

        Write-Host "Removing all registry exclusions:";

        $nextExcludedList = $nextConfig.GetExclusions()

        if ($nextExcludedList) {
            foreach ($registryExclusion in $nextExcludedList.ExcludedKeys)  {
                Write-Host "Removing:" $registryExclusion.RegistryKey
                $nextConfig.RemoveExclusion($registryExclusion.RegistryKey) | Out-Null
            }
        } else {
            Write-Host "No registry exclusions to remove."
        }
        Write-Host ""
    }
}

# Some examples of using the functions

Clear-RegistryExclusions

Get-RegistryExclusions

Add-RegistryExclusion "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer"
Add-RegistryExclusion "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DateTime\Servers\(Default)"

Get-RegistryExclusions

Remove-RegistryExclusion "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer"

Get-RegistryExclusions

Clear-RegistryExclusions

要求

Windows 版本 支持
Windows 主页
Windows 专业版
Windows 企业版
Windows 教育版
Windows IoT 企业版