in powershell, can we have several .psm1 files for a module ?


I'm writing some powershell. In order to get things cleaner i decided to write my code in modules.
So far i always work the same way :

1. I create a folder inside C:\Program Files\WindowsPowerShell\Modules\
2. I create a file with the same name as the folder in inside.
3. I invoke the create manifest file command.
4. I reference the psm1 - file with code - in the psd1.

how can i add more psm1 files inside a module.

thank you in advance.

Erwin .
Erwin PombettAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy LidbetterCommented:
Hi Toshi

I assume you mean how can you add more PSM1 (Modules) into a PSD1 (Manifest) ???

In that case you need nestedmodules to be specified in the manifest... i.e.
NestedModules =  @('database\Database.psm1', 'build\Build.psm1')

Open in new window

you can use PS1 files with functions as well...



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Erwin PombettAuthor Commented:
Hello Guy Lidbetter,

thank you for your answer.

yes ! that's my necessity ;) i dont want to create a single psm1 per module and i was wondering if we could add more on the RootModule configuration variable but you answered to my question.

*** Question :
Do this means that by removing the module and importing it,  all code in files : the one referenced by the configuration variable Rootmodule and also those under Nested modules will be refresh ?

Thank you in advance for this last info.
Guy LidbetterCommented:
If you update ANY of the modules in the nest, or the manifest you would have to manually reload the module (PSD1) in order to use them.


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.