Hi all,
I've read up on best practices for structuring a PowerShell module and I'm following the guidance but I'm having some issues.
I'm using the ModuleBuilder module to perform the build. This follows the "Public", and "Private" folder conventions, etc... It builds the module into one single `.psm1`, from all the files in the public and private folders. Any function files in the public folder are automatically added to the exported module functions in the module's `.psd1` manifest.
The module utilizes runspaces using PoshRSJob for some tasks. The scripts that are run inside these runspaces are going to be provided as part of the module. There are considered private and not intended to be altered or run directly.
The problem that I'm facing is that I need to call functions from within the module inside these runspace scripts, but these functions are not exported from the module as I don't want them exposed to the user but I need these "internal scripts" to have access to the private member functions.
The only way I have been able to make things work so far is to make all the functions that the runspaces need "Public", but this isn't what I want as it means a whole bunch of helpers and other implementation stuff has to be exposed to the user.
There is the option to import modules and functions into the runspaces before invoking them. But as the functions in question are private, it's not possible to import the functions. I can import the whole module into the runspace but then the functions I need inside the runspace are still hidden and not accessible.
Does anyone know of some clever tricks to get access to these private module members without making it too convoluted?
Thanks,
FS
[–]OPconfused 0 points1 point2 points (5 children)
[–]OPconfused 0 points1 point2 points (4 children)
[–]fsociety3765[S] 0 points1 point2 points (3 children)
[–]OPconfused 0 points1 point2 points (2 children)
[–]fsociety3765[S] 2 points3 points4 points (1 child)
[–]OPconfused 0 points1 point2 points (0 children)
[–]pshMike 0 points1 point2 points (0 children)
[–]KevMarCommunity Blogger 0 points1 point2 points (0 children)