How to Import Cmdlets Using Modules

This topic describes how to import cmdlets to a Windows PowerShell session by using a binary module.

noteNote:
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

  1. 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 user folder. You can also create module folders in the system folder, as follows:

    User\documents\windowspowershell\modules\mymodule

  2. If you create a module folder in a location other than the user or system folder, make sure that the PSModulePath environment variable includes the path to your new module folder. By default, the user and system folders are already added to the PSModulePath environment variable.

  3. Copy the cmdlet assembly into the module folder.

  4. 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, the different types of modules, the different ways to load modules, and how to restrict the elements of a module that are exported, see Writing a Windows PowerShell Module.

See Also



Show:
© 2014 Microsoft