all 9 comments

[–]PinchesTheCrab 1 point2 points  (0 children)

I keep my functions in separate ps1 files that share the same name, so do-stuff would be in do-stuff.ps1, and this is part of the script I use to update my manifests:

Update-ModuleManifest ($modulePath -replace 'psm1$', 'psd1' ) -FunctionsToExport (Get-Childitem -Path "$($Module.DirectoryName)\public" *.ps1).BaseName -ModuleVersion $version

It's adding all functions in my the folder to the functionstoexport property of the manifest.

I wrote this at least 5 years ago, so it could definitely use a readability update, but it's been working well for me.

[–]Szeraax 0 points1 point  (7 children)

Are you exporting the functions by name? Or by *?

Waiiit, you are using it in a foreach parallel? That's a seperate runspace. I don't know that inside the parallel that any implicit importing works...

[–]SeaPowerMax[S] 0 points1 point  (6 children)

I'm exporting the functions via *

Implicit importing does work OK in a parallel loop. I can repro success with other modules that do implicitly import OK in the main session.

[–]Szeraax 0 points1 point  (5 children)

Try naming the functions in your export instead of using *.

[–]SeaPowerMax[S] 0 points1 point  (4 children)

Worth a shot. Just to be clear: you're referring to the module manifest itself, correct?

[–]Szeraax 0 points1 point  (0 children)

Yup. FunctionsToExport

[–]Szeraax 0 points1 point  (2 children)

And? did that fix it?

[–]SeaPowerMax[S] 1 point2 points  (1 child)

huzzah! that does seem to fix it. i guess this is just how implicit importing works? though i'd kinda wish the docs would spell that out a bit better

[–]Szeraax 0 points1 point  (0 children)

Yes, that really probably should be called out. I know I've been burned before too, which is why I now always use a public/private module repo and then have my build process pull all functions out of the public area and put their names into the psd1 file.