I have a Powershell module and in the manifest I have declared the primary module and two nested modules. The structure of the module is as follows:
- [dir] Pivot.DockerAdmin - [manifest] Pivot.DockerAdmin.psd1 - [main module file] Pivot.DockerAdmin.psm1 - [nested script] DockerfileScripts.ps1 - [nested script] DockerCliScripts.ps1
What works The Primary Module (Pivot.DockerAdmin.psm1) can call functions in the Nested Module files (both DockerfileScripts.ps1, DockerCliScripts.ps1), without a problem. Note, there's no specific logic to include these files, other than the entry in the manifest file.
What does NOT work One Nested Module script file (DockerfileScripts.ps1) cannot call functions in the other Nested Module script file (DockerCliScripts.ps1).
The nested modules are just simple script files. So in effect, I'm using the NestedModule concept to logically group some functions in other files.
The module is setup correctly. I'm confident about this, because I even have Pester tests running on a build box without any special treatment.
I expect to be able to call a function in a nested module from another nested module, in the same way the primary module can call functions in any nested module, but this fails with an unrecognised command error.
If this is not possible are there any recommendations around organising script files within PS modules, so that a similar division of scripts / separation of concerns is possible?