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 Boolean [key, read] 指示对象包含其设置的会话。
- 如果设置适用于当前会话
- ,则为 True
如果设置位于重启后的下一个会话,则为 False。
PersistDomainSecretKey Boolean [read, write] 指示域机密注册表项是否在注册表排除列表中。 如果注册表项不在排除列表中,则重启后不会保留更改。
- 如果为 True ,则包含在排除列表中
- 否则 为 False
PersistTSCAL Boolean [read, write] 指示终端服务器客户端访问许可证 (TSCAL) 注册表项是否在 UWF 注册表排除列表中。 如果该注册表项不在排除列表中,那么,更改在重新启动后就不会保留。
- 如果为 True ,则包含在排除列表中
- 否则设置为 False

注解

注册表排除项的添加或删除,包括对 PersistDomainSecretKey 和 PersistTSCAL 的值的更改,在启用 UWF 的下一次重新启动之后生效。

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

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

示例

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

该 PowerShell 脚本创建四个函数,然后演示如何使用这些函数。

第一个函数是 Get-RegistryExclusions,它为当前会话和重新启动之后的下一个会话都显示 UWF 注册表排除项的列表。

第二个函数是 Add-RegistryExclusion,它会在你重新启动设备后将一个注册表项添加到 UWF 注册表排除列表。

第三个函数是 Remove-RegistryExclusion,它在重新启动设备后从 UWF 注册表排除列表删除一个注册表项。

第四个函数是 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 企业版