Public/Set-UWFOverlaySize.ps1
Function Set-UWFOverlaySize { <# .SYNOPSIS Sets the size of the overlay to which file and registry changes are redirected. .DESCRIPTION Sets the size of the overlay to which file and registry changes are redirected. Changes to the overlay configuration take effect on the next restart in which UWF is enabled. Before you can change the Type or MaximumSize properties, UWF must be disabled in the current session. .PARAMETER Size Size of overlay in MB .INPUTS None .EXAMPLE Set-UWFOverlaySize -Size 2048 .LINK about_functions_advanced .LINK about_CommonParameters #> [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Medium" )] Param( [Parameter( Mandatory = $true, HelpMessage = "Size of overlay in MB" )] [UInt32]$Size ) 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($env:COMPUTERNAME, "Set overlay max size to $Size MB.")) { If (!$Script:UWF -or !$Script:UWFOverlayConfig) { Throw "Unable to retrieve Unified Write Filter settings." } If ($UWF.CurrentEnabled -eq $false) { $nextConfig = Get-WMIObject -Namespace $Script:UWFNameSpace -Class UWF_OverlayConfig -Filter "CurrentSession = false" If ($nextConfig) { $nextConfig.SetMaximumSize($Size) $Message = "Set overlay max size to $Size MB." } } Else { Throw "UWF must be disabled in the current session before you can change the overlay size." } } } End { Return $Message } } |