EncryptionUtilities.psm1
$ErrorActionPreference = 'Stop' $VerbosePreference = 'SilentlyContinue' [String[]]$InclusionFilter = @("*.ps1") $ScriptsToDotSource = Get-ChildItem -Path "$($PSScriptRoot)" -Include ($InclusionFilter) -Recurse -Force | Where-Object {($_ -is [System.IO.FileInfo])} | Sort-Object -Property @('FullName') -Descending ForEach ($Script In $ScriptsToDotSource) { Try { [String]$FunctionName = "$($Script.BaseName)" Switch ($True) { {($Script.Directory.Name -imatch "^Functions$")} { [String]$LogMessage = "Attempting to dot source and export the functions contained within the following script: `"$($Script.Name)`". Please Wait..." Write-Verbose -Message ($LogMessage) . "$($Script.FullName)" #Export Module Members Export-ModuleMember -Function "$($FunctionName)" } {($Script.Directory.Name -imatch "^Internal$")} { [String]$LogMessage = "Attempting to dot source the following script: `"$($Script.Name)`". Please Wait..." Write-Verbose -Message ($LogMessage) . "$($Script.FullName)" } Default { [String]$WarningMessage = "Will not attempt to dot source or export the following script: `"$($Script.Name)`". Please Wait..." Write-Verbose -Message ($WarningMessage) } } } Catch { [String]$ErrorMessage = "Failed to dot source the following script: `"$($Script.FullName)`"" Throw [System.Management.Automation.LoopFlowException] "$($ErrorMessage)" } } |