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 保護的系統。

屬性

屬性 資料類型 限定詞 描述
識別碼 string [key] 唯一 ID。 這一律設定為 UWF_Filter
CurrentEnabled Boolean [read] 指出目前會話是否已啟用 UWF。
NextEnabled Boolean [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 首頁 No
Windows 專業版
Windows 企業版
Windows 教育版
Windows IoT 企業版 是的