Module architecture

The anatomy of a PowerShell module is quite simple. There is a folder with the name of your module. Said folder contains at least a psm1 or a psd1 file that also has the name of your module. This folder is placed in one of the module locations in $env:PSModulePath, and that's it; you're done.

Of course, there can be a little more to it, which you will discover when we talk about Just Enough Administration and Desired State Configuration. The following screenshot shows the typical structure of a module:

The psm1 file is called a script module. Script modules are, simply put, script files that are dot-sourced when being imported as a module. You can use the Import-Module cmdlet with the path to a psm1 file to manually import such a module. Once you add a psd1 file, or a module manifest, you have a manifest module. Like a shipping manifest, it describes the contents of your module.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset