Public/Set-UWFOverlayType.ps1
Function Set-UWFOverlayType { <# .SYNOPSIS Sets the type of the overlay to which file and registry changes are redirected. .DESCRIPTION Sets the type 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 OverlayType The type of storage that UWF uses to maintain the overlay. 0 = RAM-based; 1 = disk-based. .INPUTS None .EXAMPLE Example of how to use this cmdlet .LINK about_functions_advanced .LINK about_CommonParameters #> [CmdletBinding( SupportsShouldProcess = $true, ConfirmImpact = "Medium" )] Param( [Parameter( Mandatory = $true, HelpMessage = "The type of storage that UWF uses to maintain the overlay. 0 = RAM-based; 1 = disk-based." )] [ValidateSet("0", "1")] [UInt32]$OverlayType ) 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') } $OverlayTypeText = @("RAM-based", "disk-based") } Process { If ($PSCmdlet.ShouldProcess($env:COMPUTERNAME, "Set overlay type to $OverlayTypeText[$overlayType].")) { If (!$Script:UWF -or !$Script:UWFOverlayConfig) { Throw "Unable to retrieve Unified Write Filter settings." } If ($Script:UWF.CurrentEnabled -eq $false) { $nextConfig = Get-WMIObject -Namespace $Script:UWFNameSpace -Class UWF_OverlayConfig -Filter "CurrentSession = false" If ($nextConfig) { $nextConfig.SetType($OverlayType) } } Else { Throw "UWF must be disabled in the current session before you can change the overlay size." } } } End { Return $OverlayType } } |