Reputation: 20357
I have been writing a lot of my Powershell modules with this sort of logic:
function Get-ModuleName
{
#main logic, calls other functions
CallOtherFunction
}
function CallOtherFunction
{
#does something else
}
I just learned that, with this example, the function CallOtherFunction can be called by the powershell command line as if it was a separate module. This is not my intended behavior, I only want CallOtherFunction to be accessible to Get-ModuleName.
Is there a way to refactor my code for this to work as I intended?
Upvotes: 0
Views: 576
Reputation: 8432
In order to limit what is visible outside of your module, take a look at:
and
Module Manifests (.psd1 file)
Using these you can hide specific functions from external callers, but all of the functions within your module (hidden or otherwise) can still call them. This is ideal for 'helper' functions that do specific tasks for you, but which you don't want others to see/use.
Upvotes: 1