共用方式為


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保護的系統,即使重疊已滿也一樣。

屬性

屬性 資料類型 限定 符 描述
標識碼 string [key] 唯一標識碼。 這一律會設定為 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 企業版