Skip to content

About_PSModules

Carl C edited this page Aug 8, 2021 · 1 revision

About Authoring Modules

Modules in Powershell allow for multiple commands or functionalities to be grouped together into one cohesive element.

If you have a lot of configuration in your Powershell environment, the best thing you can do is to group like commands into their own module file. This makes it easier to keep track of where each function is sourced from.

Use (Get-Module [module]).Path to find the file that implements the module.

Module .psd1 Files

These files are Powershell Data files, and one use of them is to implement a "module manifest".

There are other uses for this type of file, but it's mainly for serializing data.

.psd1 files are kind of like Powershell's version of the .json file. Interesting fact: .psd1 files can be converted to json by using Convertto-json

Creating Module Manifests

Manifests can be created using New-ModuleManifest. Modules created using this command are able to be updated easily using Update-ModuleManifest.

Things I'm still confused about

I'm still confused about how to get module metadata to be attached to the [psmoduleinfo] instance itself.

There is the Metadata module, which I need to test a bit more. Then there's the Configuration module...

Modules don't need to have a .psd1 file. Older modules have manifests that are [xml] files. Since there are so many ways to serialize data in Powershell, there are so many ways to do what you want/need to do.