1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# pwshkit module root ==========================================================
# Auto-discovers and exports all functions defined under utils/**/*.ps1.
# Adding a new util = drop a .ps1 in the right utils/ subfolder. Nothing else to touch.
$ModuleRoot = $PSScriptRoot
$script:FilesToExport = @()
Get-ChildItem (Join-Path $ModuleRoot 'utils') -Filter '*.ps1' -Recurse -File |
ForEach-Object {
. $_.FullName
$script:FilesToExport += $_.FullName
}
$ExportedFunctions = Get-Command -CommandType Function |
Where-Object {
$_.ScriptBlock.File -and
$script:FilesToExport -contains $_.ScriptBlock.File
}
$ExportedAliases = Get-Alias |
Where-Object {
$_.Definition -in $ExportedFunctions.Name
}
Export-ModuleMember -Function $ExportedFunctions.Name -Alias $ExportedAliases.Name
|