Created
June 8, 2017 13:16
-
-
Save robderickson/2a0a69bffaf356701e1f14628418a72e to your computer and use it in GitHub Desktop.
Example of a PowerShell script module that uses dot sourcing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Public = @(Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue) | |
$Private = @(Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue) | |
foreach ($import in @($Public + $Private)) { | |
try { | |
. $import.fullname | |
} catch { | |
Write-Error -Message "Failed to import function $($import.fullname): $_" | |
} | |
} | |
Export-ModuleMember -Function $Public.BaseName |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment