# 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