▲ 11 r/PowerShell
Breaking huge PWSH module up to smaller parts
Hey guys, I have a personal module I've written for wrapper functions, aliases, and other tools to help me with my everyday work and pwsh use.
The module has become too big for my taste, around 2800 lines. This makes editing and searching for functions a bit tedious.
So, I've decided to try and break the module off into smaller components, each containing a handful of functions, currently being separated by regions in the module ps1m file.
I'm trying to get it to work with Invoke-Expression but it appears that the functions do not get loaded properly.
Here's how I'm trying:
$moduleFolder = (Get-Module -ListAvailable MODULENAME).ModuleBase
$functionFiles = gci $moduleFolder -Recurse | ?{$_.Extension -eq ".ps1"}
foreach ($func in $functionFiles)
{
iex $func.FullName
}
SampleFunction
SampleFunction throws the standard "not recognised as a name of a..." error message.
What do you think I'm doing wrong?
u/MFZozzy — 4 days ago