Public/Get-UWFRegistryExclusion.ps1

Function Get-UWFRegistryExclusion {
    <#
    .SYNOPSIS
        Lists the UWF registry exclusions, both for the current session as well as the next session after a restart.
    .DESCRIPTION
        Lists the UWF registry exclusions, both for the current session as well as the next session after a restart.
        Additions or removals of registry exclusions, including changes to the values of PersistDomainSecretKey and PersistTSCAL,
        take effect after the next restart in which UWF is enabled.
 
        You can only add registry keys in the HKLM registry root to the UWF registry exclusion list.
 
        You can also use UWF_RegistryFilter to exclude the domain secret registry key and the TSCAL registry key from UWF filtering.
    .INPUTS
        None
    .EXAMPLE
        Get-UWFRegistryExclusion
    .LINK
        about_functions_advanced
    .LINK
        about_CommonParameters
    #>

    [CmdletBinding()]
    Param()

    Begin { }

    Process {
        If (!$Script:UWFRegistryFilter) {
            Throw "Unable to get handle to an instance of the UWF_RegistryFilter class"
        }
        $CurrentConfig = $Script:UWFRegistryFilter | Where-Object { $_.CurrentSession -eq $true }
        $NextConfig = $Script:UWFRegistryFilter | Where-Object { $_.CurrentSession -eq $false }

        Write-Output "The following registry entries are currently excluded from UWF filtering:"
        $currentExcludedList = $currentConfig.GetExclusions()
        If ($currentExcludedList.ExcludedKeys) {
            ForEach ($registryExclusion in $currentExcludedList.ExcludedKeys) {
                Write-Output "$($registryExclusion.RegistryKey)"
            }
        } Else {
            Write-Output "None"
        }

        Write-Output " "
        Write-Output "The following registry entries will be excluded from UWF filtering after the next restart:"
        $nextExcludedList = $nextConfig.GetExclusions()
        If ($nextExcludedList.ExcludedKeys) {
            ForEach ($registryExclusion in $nextExcludedList.ExcludedKeys) {
                Write-Output "$($registryExclusion.RegistryKey)"
            }
        } Else {
            Write-Output "None"
        }
    }

    End {

    }
}