A module is a collection of related reusable functions (or cmdlets) that can easily be distributed to other PowerShell users and used in multiple scripts or directly in the console. A module is usually saved in it's own directory and consists of:
.psm1
file extension containing functions or binary assemblies (.dll
) containing cmdlets.psd1
describing the modules name, version, author, description, which functions/cmdlets it provides etc.Examples of modules:
To make it easy for PowerShell to find and import a module, it is often placed in one of the known PowerShell module-locations defined in $env:PSModulePath
.
List modules that are installed to one of the known module-locations:
Get-Module -ListAvailable
Import a module, ex. Hyper-V
module:
Import-Module Hyper-V
List available commands in a module, ex. the Microsoft.PowerShell.Archive
-module
> Import-Module Microsoft.PowerShell.Archive
> Get-Command -Module Microsoft.PowerShell.Archive
CommandType Name Version Source
----------- ---- ------- ------
Function Compress-Archive 1.0.1.0 Microsoft.PowerShell.Archive
Function Expand-Archive 1.0.1.0 Microsoft.PowerShell.Archive