How to hide "Helper" Functions in Powershell Modules
One thing I have done is use the verb-noun naming convention for functions I want to export, but leave out the hyphen in helper functions.
Then, export-modulemember *-*
takes care of only exporting what you want to export.
Just add Export-ModuleMember to the bottom of you module.
Let's say you have the following Functions in your module:
New-Function0New-Function1New-Function2New-HelperFunction0
Add these lines to the bottom of the module file:
Export-ModuleMember -function New-Function0Export-ModuleMember -function New-Function1Export-ModuleMember -function New-Function2
When you run Import-Module on this module, it will only import the functions defined by Export-ModuleMember.
Now let's say you also wanted to export an alias for New-Function1. just add this to the end of your module:
Export-ModuleMember -alias nf1
Now when you use Import-Module, it will load the functions you defined, as well as an alias (nf1) for New-Function1.
In many cases, a declared function can be replaced with a scriptblock (ie an anonymous function).