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 字串 [key] 唯一 ID。 這一律會設定為 UWF_Filter
CurrentEnabled 布林值 [read] 指出目前會話是否已啟用UWF。
NextEnabled 布林值 [read] 指出下一次重新啟動後是否啟用UWF。

備註

您必須使用系統管理員帳戶,對UWF的組態設定進行任何變更。 任何帳戶類型的使用者都可以讀取目前的組態設定。

範例

下列範例示範如何在PowerShell腳本中使用WMI提供者來啟用或停用UWF。

PowerShell 腳本會建立三個函式,以協助啟用或停用 UWF。 接著會示範如何使用每個函式。

第一個函式Disable-UWF會擷取UWF_FilterWMI 物件,並在下一個裝置重新啟動後呼叫 Disable() 方法來停用 UWF。

第二個函式Enable-UWF會擷取UWF_FilterWMI 物件,並在下次裝置重新啟動後呼叫 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 Home No
Windows 專業版 No
Windows 企業版 Yes
Windows 教育版 Yes
Windows IoT 企業版 Yes