Public/Set-UWFOverlayWarningThreshold.ps1
Function Set-UWFOverlayWarningThreshold { <# .SYNOPSIS Sets the warning threshold for monitoring the size of the Unified Write Filter (UWF) overlay. .DESCRIPTION Sets the warning threshold for monitoring the size of the Unified Write Filter (UWF) overlay. When the size of the overlay reaches or exceeds the size threshold value, UWF writes the following notification event to the event log. Message ID: UWF_OVERLAY_REACHED_WARNING_LEVEL Event code: 0x80010001L Message text: The UWF overlay size has reached WARNING level. The warning threshold must be lower than the critical threshold. .PARAMETER ThresholdSize An integer that represents the size, in megabytes, of the warning threshold level for the overlay. If size is set to 0 (zero), UWF does not raise warning threshold events. .INPUTS None .OUTPUTS Returns an HRESULT value that indicates WMI status or a WMI error. .EXAMPLE Set-UWFOverlayWarningThreshold -ThresholdSize 768 This will set the Overlay Warning Threshold to 768 MB. Note that the warning threhold must be lower than the critical threshold .LINK about_functions_advanced .LINK about_CommonParameters .LINK Set-UWFOverlayCriticalThreshold #> [CmdletBinding( SupportsShouldProcess = $true )] Param( [Parameter( Mandatory = $true, HelpMessage = "Warning threshold value" )] [Int]$ThresholdSize ) Begin { If (-not $PSBoundParameters.ContainsKey('Verbose')) { $VerbosePreference = $PSCmdlet.SessionState.PSVariable.GetValue('VerbosePreference') } If (-not $PSBoundParameters.ContainsKey('WhatIf')) { $WhatIfPreference = $PSCmdlet.SessionState.PSVariable.GetValue('WhatIfPreference') } If (-not $PSBoundParameters.ContainsKey('Confirm')) { $ConfirmPreference = $PSCmdlet.SessionState.PSVariable.GetValue('ConfirmPreference') } If (-not $PSBoundParameters.ContainsKey('ErrorAction')) { $ErrorActionPreference = $PSCmdlet.SessionState.PSVariable.GetValue('ErrorActionPreference') } } Process { If ($PSCmdlet.ShouldProcess()) { If (!$Script:UWFOverlay) { $ExitCode = 424 Throw "Unable to get handle to an instance of the UWF_Overlay class" } $Warning = $Script:UWFOverlay.SetWarningThreshold($ThresholdSize) $ExitCode = $Warning.ReturnValue } } End { If ($Null -eq $ExitCode) { # 424 Failed Dependency $ExitCode = 424 } If ($ExitCode -eq 0) { Write-Output "Overlay warning threshold has been set to $ThresholdSize MB" } Return $("{0:x0}" -f $ExitCode) } } |