Module
suggest changeA 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:
- One or more code files with the
.psm1
file extension containing functions or binary assemblies (.dll
) containing cmdlets - A module manifest
.psd1
describing the modules name, version, author, description, which functions/cmdlets it provides etc. - Other requirements for it to work incl. dependencies, scripts etc.
Examples of modules:
- A module containing functions/cmdlets that perform statistics on a dataset
- A module for querying and configuring databases
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
.
Demo
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
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents