Overview β
Filetypes β
.ps1: general powershell script.psm1: powershell module file.psd1: powershell module manifest
Module Structure β
<modname>.psm1: the module entry file at module root, should have the same name as parent folder.<modname>.psd1(optional): the module manifest at module root containing module description such asAuthor,Versionand so on.*.ps1: arbitrary scripts that can be sourced in<modname>.psm1- you can place such scripts in any manner since they wouldn't be executed unless you source it the module entry
.psm1manually.
- you can place such scripts in any manner since they wouldn't be executed unless you source it the module entry
Search Path β
$env:PSModulePath stores one or more paths to search module on any *-Module operation. Each folder added should be a parent containing module folders.
./YourModules/
βββ InvokeBuild
βββ platyPS
βββ ...
βββ PSFzf1
2
3
4
5
2
3
4
5
To add your own module path, use:
ps1
$env:PSModulePath += "$([IO.Path]::PathSeparator)$customModulePath"1
Member Exporting β
- Explicit
Export-ModuleMemberwithin*.psm1file only. - Implicit exporting when
Export-ModuleMemberis not used- all functions and aliases are exported
- other member are hidden inside module
NOTE
See: Export-ModuleMember
TIP
Using explicit Export-ModuleMember is always the best practice.