The “best practice” and proper way of handling this then is to add an entry to the array in this file every time you create a new function. Manually. What a pain in the ass right? But there’s a better way!
If you haven’t seen psake before you can take a look later. Start up PowerShell as Administrator and install psake from the PowerShell Gallery using
Install-Module psake
and then you’re ready to go.How does psake work? It’s the PowerShell equivalent of a Makefile. Basically:
-
You add a file in the root of your module called psakefile.ps1
-
When you run Invoke-psake from that location, it will load and execute the file
For a one-off module with one or two functions, it’s probably not worth it, but once you get to several functions (or if you’re building modules regularly), this looks like a time-saver.