Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load Multiple Modules (.psm1) using a single psd1 file

I want to organize functions into multiple .psm1 files and have them loaded by a single Module Manifest file (.psd1) -- such that Only the .psd1 file would need to have the same name as the module.

I think it should be possible. Can anyone help me out please ?

like image 387
Angshuman Agarwal Avatar asked Apr 23 '12 15:04

Angshuman Agarwal


People also ask

How do I run a psd1 file?

PSD1 files are manifests and only matter when you make a module "ModuleName" in a folder named "ModuleName" with the 2 files "modulename. psd1" and "modulename. psm1". The PSD1 manifest can be created using the New-ModuleManifest cmdlet.

What are psd1 files used for?

A module manifest is a PowerShell data file ( . psd1 ) that describes the contents of a module and determines how a module is processed. The manifest file is a text file that contains a hash table of keys and values.

How do I install all PowerShell modules?

Installing PowerShell modules from the PowerShell Gallery is the easiest way to install modules. To install a package or module from the Gallery, we use the command: Install-Module or Install-Script cmdlet, depending on the package type.


1 Answers

  1. Launch the Powershell ISE
  2. Use the New-ModuleManifest command
  3. Follow the instructions here - How to Write a Module Manifest. When asked for nested modules, key in the module as Modulepath\Modulename.psm1
  4. Finally, once the .psd1 file is created, load / import it using Import-Module <<module-name>>
like image 152
Angshuman Agarwal Avatar answered Sep 27 '22 20:09

Angshuman Agarwal