February 2019
Intermediate to advanced
626 pages
15h 51m
English
When a module is divided in this manner, the root module must contain everything required to load the module content. This is most often achieved by dot-sourcing each of the files in the sub-folders adjacent to the root module. One possible way to do this is to use Get-ChildItem to find all of the ps1 files beneath a certain point and dot-source those.
The following snippet uses this approach:
Get-ChildItem (Join-Path $psscriptroot 'private') { . $_.FullName}$functionsToExport = Get-ChildItem (Join-Path $psscriptroot 'public') { . $_.FullName $_.BaseName}Export-ModuleMember -Function $functionsToExport
The snippet assumes Export-ModuleMember is to be used, and that the manifest has FunctionsToExport set to *
Read now
Unlock full access