How to Import Cmdlets Using Modules
This article describes how to import cmdlets to a PowerShell session by using a binary module.
Note
The members of modules can include cmdlets, providers, functions, variables, aliases, and much more. Snap-ins can contain only cmdlets and providers.
How to load cmdlets using a module
Create a module folder that has the same name as the assembly file in which the cmdlets are implemented. In this procedure, the module folder is created in the Windows
system32
folder.%SystemRoot%\system32\WindowsPowerShell\v1.0\Modules\mymodule
Make sure that the
PSModulePath
environment variable includes the path to your new module folder. By default, the system folder is already added to thePSModulePath
environment variable. To view thePSModulePath
, type:$env:PSModulePath
.Copy the cmdlet assembly into the module folder.
Add a module manifest file (
.psd1
) in the module's root folder. PowerShell uses the module manifest to import your module. For more information, see How to Write a PowerShell Module Manifest.Run the following command to add the cmdlets to the session:
Import-Module [Module_Name]
This procedure can be used to test your cmdlets. It adds all the cmdlets in the assembly to the session. For more information about modules, see Writing a Windows PowerShell Module.
See also
PowerShell