UWF_Filter

启用或禁用统一写入筛选器 (UWF),重置 UWF 的配置设置,以及关闭或重启设备。

语法

class UWF_Filter{
    [key]  string Id;
    [read] boolean CurrentEnabled;
    [read] boolean NextEnabled;
    UInt32 Enable();
    UInt32 Disable();
    UInt32 ResetSettings();
    UInt32 ShutdownSystem();
    UInt32 RestartSystem();
};

成员

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

方法

方法 说明
UWF_Filter.Enable 在下次重启时启用 UWF。
UWF_Filter.Disable 在下次重启时禁用 UWF。
UWF_Filter.ResetSettings 将 UWF 设置还原到安装时捕获的 orig inal 状态。
UWF_Filter.ShutdownSystem 安全关闭受 UWF 保护的系统,即使覆盖层已满。
UWF_Filter.RestartSystem 安全重启受 UWF 保护的系统,即使覆盖层已满。

属性

属性 数据类型 限定符 说明
Id string [key] 唯一 ID。 这始终设置为 UWF_Filter
CurrentEnabled Boolean [read] 指示是否为当前会话启用了 UWF。
NextEnabled Boolean [read] 指示是否在下次重启后启用 UWF。

注解

要对 UWF 的配置设置进行任何更改,必须使用管理员帐户。 具有任何类型帐户的用户都可读取当前配置设置。

示例

以下示例演示如何在 PowerShell 脚本中使用 WMI 提供程序启用或禁用 UWF。

PowerShell 脚本创建 3 个函数来帮助启用或禁用 UWF。 然后,演示每个函数的使用方式。

第一个函数是 Disable-UWF,它为 UWF_Filter 检索 WMI 对象,并调用 Disable () 方法,以在下次设备重启后禁用 UWF。

第二个函数是 Enable-UWF,它为 UWF_Filter 检索 WMI 对象,并调用 Enable() 方法,以在下次设备重启后启用 UWF。

第三个函数是 Display-UWFState,它检查 UWF_Filter 对象的属性,并输出 UWF_Filter 的当前设置。

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

# Create a function to disable the Unified Write Filter driver after the next restart.
function Disable-UWF() {

# Retrieve the UWF_Filter settings.
    $objUWFInstance = Get-WMIObject -namespace $NAMESPACE -class UWF_Filter;

    if(!$objUWFInstance) {
        "Unable to retrieve Unified Write Filter settings."
        return;
    }

# Call the method to disable UWF after the next restart.  This sets the NextEnabled property to false.

    $retval = $objUWFInstance.Disable();

# Check the return value to verify that the disable is successful
    if ($retval.ReturnValue -eq 0) {
        "Unified Write Filter will be disabled after the next system restart."
    } else {
        "Unknown Error: " + "{0:x0}" -f $retval.ReturnValue
    }
}

# Create a function to enable the Unified Write Filter driver after the next restart.
function Enable-UWF() {

# Retrieve the UWF_Filter settings.
    $objUWFInstance = Get-WMIObject -namespace $NAMESPACE -class UWF_Filter;

    if(!$objUWFInstance) {
        "Unable to retrieve Unified Write Filter settings."
    return;
    }

# Call the method to enable UWF after the next restart.  This sets the NextEnabled property to false.

    $retval = $objUWFInstance.Enable();

# Check the return value to verify that the enable is successful
    if ($retval.ReturnValue -eq 0) {
        "Unified Write Filter will be enabled after the next system restart."
    } else {
        "Unknown Error: " + "{0:x0}" -f $retval.ReturnValue
    }
}

# Create a function to display the current settings of the Unified Write Filter driver.
function Display-UWFState() {

# Retrieve the UWF_Filter object
    $objUWFInstance = Get-WmiObject -Namespace $NAMESPACE -Class UWF_Filter;

    if(!$objUWFInstance) {
        "Unable to retrieve Unified Write Filter settings."
        return;
    }

# Check the CurrentEnabled property to see if UWF is enabled in the current session.
    if($objUWFInstance.CurrentEnabled) {
        $CurrentStatus = "enabled";
    } else {
        $CurrentStatus = "disabled";
    }

# Check the NextEnabled property to see if UWF is enabled or disabled after the next system restart.
    if($objUWFInstance.NextEnabled) {
        $NextStatus = "enabled";
    } else {
        $NextStatus = "disabled";
    }
}

# Some examples of how to call the functions

Display-UWFState

"Enabling Unified Write Filter"
Enable-UWF

Display-UWFState

"Disabling Unified Write Filter"
Disable-UWF

Display-UWFState

要求

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