Skip to content

Instantly share code, notes, and snippets.

@robderickson
Created June 8, 2017 13:16
Show Gist options
  • Save robderickson/2a0a69bffaf356701e1f14628418a72e to your computer and use it in GitHub Desktop.
Save robderickson/2a0a69bffaf356701e1f14628418a72e to your computer and use it in GitHub Desktop.
Example of a PowerShell script module that uses dot sourcing
$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