r/PowerShell • • Dec 17 '25

Question Multiple files

Unfortunately, large PowerShell scripts cannot easily be distributed across multiple files in a project. What is your best strategy for this?

6 Upvotes

25 comments sorted by

View all comments

Show parent comment

1

u/jdl_uk Dec 17 '25

what do yo mean ?

cause if I do connect graph it only lids the mggraph.authentication module not all the mggraph modules

There's 2 things here. Partially I mean that when I switched off autoloading my powershell start time went from 5-10s to 1-2s. I also mean that, in the same way that C# limits what you have available to what namespaces you reference, it's useful if your completions list is limited based on what you're using.

but saving the change to the module and using import module force would reflect that change straight away, same as you saving the change to your script file

That's if you're using Import-Module, and yeah I've gone back and forth between those 2.

But you're still arguing I should take the option that has extra steps over the one that doesn't, every time I edit the module code. I'm not going to do that, even if you don't think the extra steps (even if it's only 1 step) matter.

My opinion is id rather write a module which is consistent with the existing way other people write and distribute code/modules
my stuff starts out as a script (normally) just like yours then I wrap a function/module when i "procuctionise" it

That's a fair opinion and it's why I used to prefer modules over scripts - modules were the "Powershell way". I'm just dissatisfied with the developer experience.

Another thing that might be relevant is that most of the scripts I write are either used by developers (who'd rather just clone the repo and reference the file than install a module) or by CI/CD pipelines (where powershell norms don't always make sense).