PS: Moving To Modules
Description:
So I have re-ordered most my scripts into Modules now and set them to follow this guide.
To Resolve:
-
Essentially, at the root of your module, you create two folders
Public
andPrivate
. -
Under
Public
you place all your functions in one function per file that will get dot sourced when you import your function usingImport-Module yourModuleName
-
Under
Private
you place psm1 files that will not get called. Instead, in the public functions, you call the module in your private folder like so:1 2 3 4
If (-not (Test-path "$PSScriptRoot\..\Private\helpers.psm1")) { Import-Module $PSScriptRoot\..\Private\helpers.psm1" }
-
See Part 2 to see my current setup.
Comments