Public/Search-UWFRegistryExclusion.ps1
Function Search-UWFRegistryExclusion { <# .SYNOPSIS Checks if a specific registry key is excluded from being filtered by Unified Write Filter (UWF). .DESCRIPTION Checks if a specific registry key is excluded from being filtered by Unified Write Filter (UWF). .PARAMETER RegistryKey A string that contains the full path of the registry key. .INPUTS System.String .OUTPUTS System.Boolean Returns an HRESULT value that indicates WMI status or a WMI error. .EXAMPLE Search-UWFRegistryExclusion -RegistryKey "HKLM\SOFTWARE" .LINK about_functions_advanced .LINK about_CommonParameters #> [CmdletBinding( ConfirmImpact = "Medium" )] Param( [Parameter( Mandatory = $true, HelpMessage = "A string that contains the full path of the registry key." )] [String]$RegistryKey ) 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 (!$Script:UWFRegistryFilter) { $ExitCode = 424 Throw "Unable to get handle to an instance of the UWF_RegistryFilter class" } $FindExclusion = $Script:UWFRegistryFilter.FindExclusion($RegistryKey) $ExitCode = $FindExclusion.ReturnValue } End { If ($Null -eq $ExitCode) { # 424 Failed Dependency $ExitCode = 424 } If ($ExitCode -eq 0) { Return $FindExclusion.bFound } Else { Return $("{0:x0}" -f $ExitCode) } } } |