Module directory
A module that is not located in a directory pointed at by
$env:PSModulePath
can be loaded with the
import-module
cmdlet.
A handy (
automatic) variable when writing PowerShell modules is
$PSScriptRoot
: when evaluated in a module script (
.psm1
), its value corresponds to the path of the module directory. Thus, with this value, it is possible to reference other resources that are located in the module directory.
Cmdlets
get-module -listAvailable
shows available modules.
get-module -all
lists the modules thare loaded in the actual PowerShell session along with their exported commands.
get-command -name Microsoft.PowerShell.Management
shows the commands in the module Microsoft.PowerShell.Management.
get-command | group-object moduleName | select-object count, name
groups commands by their module name.
Static and dynamic modules
There are static and dynamic modules.
Dynamic modules exist in memory only, while static modules are stored on disk.