UWFModule.psm1

<#
  File: UWFModule.psm1
  Author: Casper Stekelenburg
  Copyright: � 2019 Casper Stekelenburg. All rights reserved.
  Notes: The software is provided "as is", without warranty of any kind, express or implied, including
                but not limited to the warranties of merchantability, fitness for a particular purpose and
                noninfringement. In no event shall the authors or copyright holders be liable for any claim,
                damages or other liability, whether in an action of contract, tort or otherwise, arising from,
                out of or in connection with the software or the use or other dealings in the software.
#>

#Set-StrictMode -Version 2

# Functions in this module:
#Get public and private function definition files.
$Public = @( Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue )
$Private = @( Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue )

#Dot source the files
Foreach ($import in @($Public + $Private)) {
    Try {
        . $import.fullname
    } Catch {
        Write-Error -Message "Failed to import function $($import.fullname): $_"
    }
}

<#
    Here I might...
        Read in or create an initial config file and variable
        Export Public functions ($Public.BaseName) for WIP modules
        Set variables visible to the module and its functions only
#>


#region Variables
$Script:UWFNameSpace = "root\standardcimv2\embedded"
$Script:UWF = Get-WmiObject -Namespace $Script:UWFNameSpace -Class UWF_Filter -ErrorAction SilentlyContinue
$Script:UWFOverlay = Get-WMIObject -Namespace $Script:UWFNameSpace -Class UWF_Overlay -ErrorAction SilentlyContinue
$Script:UWFOverlayConfig = Get-WMIObject -Namespace $Script:UWFNameSpace -Class UWF_OverlayConfig -ErrorAction SilentlyContinue
$Script:UWFRegistryFilter = Get-WmiObject -Namespace $Script:UWFNameSpace -Class UWF_RegistryFilter -ErrorAction SilentlyContinue
$Script:UWFServicing = Get-WmiObject -Namespace $Script:UWFNameSpace -Class UWF_Servicing -ErrorAction SilentlyContinue
$Script:UWFVolume = Get-WmiObject -Namespace $Script:UWFNameSpace -Class UWF_Volume -ErrorAction SilentlyContinue
#endregion Variables

#region feature test
$UWFFeatureState = (Get-WindowsOptionalFeature -FeatureName "Client-UnifiedWriteFilter" -Online -ErrorAction SilentlyContinue).State
If ($UWFFeatureState -eq "Disabled") {
    Write-Warning "The Unified Write Filter Feature is currently disabled. Use Enable-UWFFeature to enable it before useing this module."
}
#endregion feature test

Export-ModuleMember -Function $Public.Basename