Public/Remove-UWFVolumeExclusion.ps1
Function Remove-UWFVolumeExclusion { <# .SYNOPSIS Removes a specific file or folder from the file exclusion list for a volume protected by Unified Write Filter (UWF). .DESCRIPTION Removes a specific file or folder from the file exclusion list for a volume protected by Unified Write Filter (UWF). You must use an administrator account to remove file or folder exclusions, and you must restart the device for this change to take effect. .PARAMETER FileName A string that contains the full path of the file or folder relative to the volume. .INPUTS None .OUTPUTS Returns an HRESULT value that indicates WMI status or a WMI error constant. .EXAMPLE Remove-UWFVolumeExclusion .LINK about_functions_advanced .LINK about_CommonParameters #> [CmdletBinding()] Param( [Parameter( Mandatory = $true )] [String]$FileName ) Begin { } Process { If (!$Script:UWFVolume) { $ExitCode = 424 Throw "Unable to get handle to an instance of the UWF_Volume class" } $RemoveExclusion = $Script:UWFVolume.RemoveExclusion($FileName) $ExitCode = $RemoveExclusion.ReturnValue } End { If ($Null -eq $ExitCode) { # 424 Failed Dependency $ExitCode = 424 } If ($ExitCode -eq 0) { Write-Warning "Removing file and folder exclusion for $FileName on the next restart" } Return $("{0:x0}" -f $ExitCode) } } |