Hardening.psm1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# +++++++++++++++++++++++++++++++++++++++
# + Define Module configuration
$Script:ModulePath = $PSScriptRoot

# +++++++++++++++++++++++++++++++++++++++
# + Get powershell files
$Public = @( Get-ChildItem -Path "$ModulePath\Public\*.ps1" -ErrorAction SilentlyContinue )
$Private = @( Get-ChildItem -Path "$ModulePath\Private\*.ps1" -ErrorAction SilentlyContinue )

# +++++++++++++++++++++++++++++++++++++++
# + Dot source all powershell function
@($Public + $Private) | ForEach-Object {
    Try {
        Write-Verbose "Load $($_.FullName)"
        . $_.FullName
    }
    Catch {
        write-Error -Message "Failed to import function $($_.FullName): $($_.Exception.Message)"
    }
}