UWF_Volume

이 클래스는 UWF(통합 쓰기 필터)로 보호되는 볼륨을 관리합니다.

구문

class UWF_Volume {
    [key, Read] boolean CurrentSession;
    [key, Read] string DriveLetter;
    [key, Read] string VolumeName;
    [Read, Write] boolean BindByDriveLetter;
    [Read] boolean CommitPending;
    [Read, Write] boolean Protected;

    UInt32 CommitFile([in] string FileFullPath);
    UInt32 CommitFileDeletion(string FileName);
    UInt32 Protect();
    UInt32 Unprotect();
    UInt32 SetBindByDriveLetter(boolean bBindByVolumeName);
    UInt32 AddExclusion(string FileName);
    UInt32 RemoveExclusion(string FileName);
    UInt32 RemoveAllExclusions();
    UInt32 FindExclusion([in] string FileName, [out] bFound);
    UInt32 GetExclusions([out, EmbeddedInstance("UWF_ExcludedFile")] string ExcludedFiles[]);

};

구성원

다음 표에는 이 클래스에 속하는 메서드 및 속성이 나와 있습니다.

메서드

메서드 설명
UWF_Volume.AddExclusion 파일 또는 폴더를 byUWF로 보호되는 볼륨의 파일 제외 목록에 추가합니다.
UWF_Volume.CommitFile UWF(통합 쓰기 필터)로 보호되는 볼륨에서 지정된 파일의 오버레이에서 실제 볼륨으로 변경 내용을 커밋합니다.
UWF_Volume.CommitFileDeletion 볼륨에서 보호된 파일을 삭제하고 삭제 항목을 실제 볼륨에 커밋합니다.
UWF_Volume.FindExclusion 특정 파일 또는 폴더가 byUWF로 보호되는 볼륨의 제외 목록에 있는지 여부를 확인합니다.
UWF_Volume.GetExclusions byUWF로 보호되는 볼륨의 모든 파일 제외 목록을 검색합니다.
UWF_Volume.Protect 다시 시작한 후 UWF를 사용하도록 설정한 경우 다음 시스템을 다시 시작한 후 볼륨을 보호합니다.
UWF_Volume.RemoveAllExclusions UWF로 보호되는 볼륨에 대한 파일 제외 목록에서 모든 파일 및 폴더를 제거합니다.
UWF_Volume.RemoveExclusion byUWF로 보호되는 볼륨의 파일 제외 목록에서 특정 파일 또는 폴더를 제거합니다.
UWF_Volume.SetBindByDriveLetter UWF 볼륨이 드라이브 문자 또는 볼륨 이름으로 실제 볼륨에 바인딩되어 있는지 여부를 나타내는 BindByDriveLetter 속성을 설정합니다.
UWF_Volume.Unprotect 다음 시스템을 다시 시작한 후 볼륨의 UWF 보호를 사용하지 않도록 설정합니다.

속성

속성 데이터 형식 한정자 Description
BindByDriveLetter Boolean [read, write] 볼륨에서 사용하는 바인딩 유형을 나타냅니다.
- True 이면 볼륨을 DriveLetter(느슨한 바인딩)
- False 로 바인딩하여 볼륨을 VolumeName (꽉 바인딩)으로 바인딩합니다.
CommitPending Boolean [읽기] Microsoft용으로 예약되어 있습니다.
CurrentSession Boolean [key, read] 개체에 설정이 포함된 세션을 나타냅니다.
- True이면 현재 세션
- 에 대한 설정이False이면 다시 시작한 다음 세션에 대한 설정입니다.
DriveLetter string [키, 읽기] 볼륨의 드라이브 문자입니다. 볼륨에 드라이브 문자가 없으면 이 값은 NULL입니다.
Protected Boolean [read, write] CurrentSessiontrue이면 볼륨이 현재 UWF로 보호되는지 여부를 나타냅니다.
CurrentSessionfalse이면 디바이스를 다시 시작한 후 볼륨이 다음 세션에서 보호되는지 여부를 나타냅니다.
VolumeName string [키, 읽기] 현재 시스템에서 볼륨의 고유 식별자입니다. VolumeName은 볼륨에 대한 Win32_Volume 클래스의 DeviceID 속성과 동일합니다.

설명

관리자 계정을 사용하여 속성을 변경하거나 구성 설정을 변경하는 메서드를 호출해야 합니다.

UWF 보호 설정 또는 해제

다음 예제에서는 PowerShell 스크립트에서 WMI(Windows Management Instrumentation) 공급자를 사용하여 UWF를 통해 볼륨을 보호하도록 설정하거나 해제하는 방법을 보여줍니다.

PowerShellscript는 볼륨에 대해 UWF 보호를 설정하거나 해제하는 Set-ProtectVolume 함수를 만듭니다. 그런 다음 이 스크립트는 함수를 사용하는 방법을 보여줍니다.

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

# Define common parameters

$CommonParams = @{"namespace"=$NAMESPACE; "computer"=$COMPUTER}

# Create a function to protect or unprotect a volume based on the drive letter of the volume

function Set-ProtectVolume($driveLetter, [bool] $enabled) {

# Each volume has two entries in UWF_Volume, one for the current session and one for the next session after a restart
# You can only change the protection status of a drive for the next session

    $nextConfig = Get-WMIObject -class UWF_Volume @CommonParams |
        where {
            $_.DriveLetter -eq "$driveLetter" -and $_.CurrentSession -eq $false
        };

# If a volume entry is found for the drive letter, enable or disable protection based on the $enabled parameter

    if ($nextConfig) {

        Write-Host "Setting drive protection on $driveLetter to $enabled"

        if ($Enabled -eq $true) {
            $nextConfig.Protect() | Out-Null;
        } else {
            $nextConfig.Unprotect() | Out-Null;
        }
    }

# If the drive letter does not match a volume, create a new UWF_volume instance

    else {
    Write-Host "Error: Could not find $driveLetter. Protection is not enabled."
    }
}

# The following sample commands demonstrate how to use the Set-ProtectVolume function
# to protect and unprotect volumes

Set-ProtectVolume "C:" $true
Set-ProtectVolume "D:" $true

Set-ProtectVolume "C:" $false

UWF 파일 및 폴더 제외 목록 관리

다음 예제에서는 PowerShell 스크립트에서 WMI 공급자를 사용하여 UWF 파일 및 폴더 제외 목록을 관리하는 방법을 보여줍니다. PowerShell 스크립트는 4개의 함수를 만든 다음 이 함수를 사용하는 방법을 보여줍니다.

첫 번째 함수인 Get-FileExclusions는 볼륨에 있는 UWF 파일 제외 목록을 표시합니다. 현재 세션 및 다시 시작한 후 다음 세션 모두에 대한 제외 목록이 표시됩니다.

두 번째 함수인 Add-FileExclusion은 지정된 볼륨의 UWF 제외 목록에 파일 또는 폴더를 추가합니다. 다시 시작 후 다음 세션에 대한 제외 목록이 추가됩니다.

세 번째 함수인 Remove-FileExclusion은 지정된 볼륨에 대한 UWF 제외 목록에서 파일 또는 폴더를 제거합니다. 다시 시작 후 다음 세션에 대한 제외 목록이 제거됩니다.

네 번째 함수인 Clear-FileExclusions는 지정된 볼륨에서 모든 UWF 파일 및 폴더 제외 목록을 제거합니다. 다시 시작 후 다음 세션에 대한 제외 목록이 제거됩니다.

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

# Define common parameters

$CommonParams = @{"namespace"=$NAMESPACE; "computer"=$COMPUTER}

function Get-FileExclusions($driveLetter) {

# This function lists the UWF file exclusions for a volume, both
# for the current session as well as the next session after a restart 

# $driveLetter is the drive letter of the volume

# Get the UWF_Volume configuration for the current session

    $currentConfig = Get-WMIObject -class UWF_Volume @CommonParams |
        where {
            $_.DriveLetter -eq "$driveLetter" -and $_.CurrentSession -eq $true
        };

# Get the UWF_Volume configuration for the next session after a restart

    $nextConfig = Get-WMIObject -class UWF_Volume @CommonParams |
        where {
            $_.DriveLetter -eq "$driveLetter" -and $_.CurrentSession -eq $false
        };

# Display file exclusions for the current session

    if ($currentConfig) {

        Write-Host "The following files and folders are currently excluded from UWF filtering for $driveLetter";

        $currentExcludedList = $currentConfig.GetExclusions()

        if ($currentExcludedList) {
            foreach ($fileExclusion in $currentExcludedList.ExcludedFiles)  {
                Write-Host "  " $fileExclusion.FileName
            }
        } else {
            Write-Host "  None"
        }
    } else {
        Write-Error "Could not find drive $driveLetter";
}

# Display file exclusions for the next session after a restart

    if ($nextConfig) {

        Write-Host ""
        Write-Host "The following files and folders will be excluded from UWF filtering for $driveLetter after the next restart:";

        $nextExcludedList = $nextConfig.GetExclusions()

        if ($nextExcludedList) {
            foreach ($fileExclusion in $nextExcludedList.ExcludedFiles)  {
                Write-Host "  " $fileExclusion.FileName
            }
        } else {
            Write-Host "  None"
        }

        Write-Host ""
    }
}

function Add-FileExclusion($driveLetter, $exclusion) {

# This function adds a new UWF file exclusion to a volume
# The new file exclusion takes effect the next time the device is restarted and UWF is enabled

# $driveLetter is the drive letter of the volume
# $exclusion is the path and filename of the file or folder exclusion

# Get the configuration for the next session for the volume

    $nextConfig = Get-WMIObject -class UWF_Volume @CommonParams |
        where {
            $_.DriveLetter -eq "$driveLetter" -and $_.CurrentSession -eq $false
        };

# Add the exclusion

    if ($nextConfig) {
        $nextConfig.AddExclusion($exclusion) | Out-Null;
        Write-Host "Added exclusion $exclusion for $driveLetter";
    } else {
        Write-Error "Could not find drive $driveLetter";
    }
}

function Remove-FileExclusion($driveLetter, $exclusion) {

# This function removes a UWF file exclusion from a volume
# The file exclusion is removed the next time the device is restarted

# $driveLetter is the drive letter of the volume
# $exclusion is the path and filename of the file or folder exclusion

# Get the configuration for the next session for the volume

    $nextConfig = Get-WMIObject -class UWF_Volume @CommonParams |
        where {
            $_.DriveLetter -eq "$driveLetter" -and $_.CurrentSession -eq $false
        };

# Try to remove the exclusion

    if ($nextConfig) {
        try {
            $nextConfig.RemoveExclusion($exclusion) | Out-Null;
            Write-Host "Removed exclusion $exclusion for $driveLetter";
        } catch {
            Write-Host "Could not remove exclusion $exclusion on drive $driveLetter"
        }
    } else {
        Write-Error "Could not find drive $driveLetter";
    }
}

function Clear-FileExclusions($driveLetter) {

# This function removes all UWF file exclusions on a volume
# The file exclusions are removed the next time the device is restarted

# $driveLetter is the drive letter of the volume

# Get the configuration for the next session for the volume

    $nextConfig = Get-WMIObject -class UWF_Volume @CommonParams |
        where {
            $_.DriveLetter -eq "$driveLetter" -and $_.CurrentSession -eq $false
        };

# Remove all file and folder exclusions

    if ($nextConfig) {
        $nextConfig.RemoveAllExclusions() | Out-Null;
        Write-Host "Cleared all exclusions for $driveLetter";
    } else {
        Write-Error "Could not clear exclusions for drive $driveLetter";
    }
}

# Some examples of using the functions

Clear-FileExclusions "C:"

Add-FileExclusion "C:" "\Users\Public\Public Documents"
Add-FileExclusion "C:" "\myfolder\myfile.txt"

Get-FileExclusions "C:"

Remove-FileExclusion "C:" "\myfolder\myfile.txt"

Get-FileExclusions "C:"

요구 사항

Windows 버전 지원됨
Windows Home No
Windows Pro No
Windows Enterprise Yes
Windows Education Yes
Windows IoT Enterprise