PS: Helper Functions
Description:
Helper functions are functions that are used in modules that are not meant to be used as a public function, but rather a “helper”. These go under the folder Private
at the root of your module and you call them into scripts like:
1
2
3
4
5
6
7
Begin
{
If (-not (Test-path "$PSScriptRoot\..\Private\helpers.psm1"))
{
Import-Module $PSScriptRoot\..\Private\helpers.psm1"
}
}
You place that in the Begin {}
block of your functions to call helper functions. And because your modules root psm1 file ignores that directory, you never see these functions get imported when you do Import-Module yourModuleName
.
To Resolve:
-
I have made a couple of these over the years but have since just placed these functions into my template since I don’t always distribute modules completely and instead usually prefer self-contained scripts.
Comments