CmdLets & Modules
Last updated
Last updated
A is a single-feature command that manipulates objects in PowerShell. Cmdlets are written in C# or other languages and then complise for PowerShell usage. PowerShell is similar to a script; it can contain cmdlets, functions, other scripts, etc.
The most basic way to create a module is to save a Windows PowerShell script as .psm1
. This is the "meat" of the module.
A Powershell data file (.psd1
) is called a module manifest file and contains information such as version numbers, authors, cmdlets used, etc.
is the best place to search for modules, scripts, etc. We can interact with it directly through PowerShell with the PowerShellGet
cmdlet.
PowerShell will auto-import a module installed the first time we run a cmdlet or function from it. This is not true for modules that we bring onto the host from elsewhere, e.g. GitHub.
It is possible to permanently add a module by adding the files to the referenced directories in the PSModulePath
.
After loading the module, we can list its parameters.
A host's execution policy might prevent us from running scripts.
Another way to bypass the execution policy and not leave a persistent change (as above) is to change it at the process level using -scope
. This way the change will be reverted once we close the session.
.