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 设置还原到安装时捕获的原始状态。
UWF_Filter.ShutdownSystem 安全关闭受 UWF 保护的系统,即使覆盖已满。
UWF_Filter.RestartSystem 安全重启受 UWF 保护的系统,即使覆盖已满。

属性

属性 数据类型 限定 符 描述
ID 字符串 [key] 唯一 ID。 这始终设置为 UWF_Filter
CurrentEnabled 布尔 [read] 指示是否为当前会话启用了 UWF。
NextEnabled 布尔 [read] 指示是否在下次重启后启用 UWF。

备注

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

示例

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

PowerShell 脚本创建三个函数来帮助启用或禁用 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 企业版