How to Import a Module

Updated: August 18, 2010

Applies To: Windows PowerShell 2.0, Windows PowerShell 3.0

Modules are packages of Windows PowerShell commands, such as cmdlets and functions, and items, such as providers, variables, aliases, and drives. If you have downloaded, installed, or received a module, use the procedure in this topic to import or add it to your Windows PowerShell session.

Before Importing: Install the Module

If you receive a module as a folder with files in it, you need to install it on your computer before you can import it into Windows PowerShell. Typically, you install the module simply by copying the module to a particular location on a drive that your computer can access.

Most modules are installed for you. Windows PowerShell comes with several pre-installed modules. In Windows Server 2008 R2, the Add Features Wizard in Server Manager automatically installs the feature modules that you select. Many other modules come in an installer or setup program that installs the module.

For information about installing modules, see about_Modules.

How to Import a Module

To use the commands in a module, import the module into a Windows PowerShell session. To import modules from a default module location into the current session, use the following command format:

import-module <module-name>

For example, the following command imports the BitsTransfer module into the current session:

import-module BitsTransfer

To import a module that is not in a default module location, use the fully qualified path to the module folder in the command. For example, to add the TestCmdlets module in the C:\ps-test directory to your session, type the following:

import-module c:\ps-test\TestCmdlets

For more information about adding modules to your session, see Import-Module.

How to Import System Modules

In Windows 7 and Windows Server 2008 R2, you can start a Windows PowerShell session that automatically imports commands from all modules in your %Windir%\System32\WindowsPowerShell\1.0\Modules directory. The session also runs with the privileges of your Administrator account (the Run as administrator option.

To start Windows PowerShell with the Import System Modules task, use either of the following procedures:

  • In the taskbar, right-click the Windows PowerShell icon, and then click Import System Modules.
  • Click Start, point to Administrative Tools, and then click Windows PowerShell Modules.

Import-Module Warning Message

The commands that a module exports should follow the Windows PowerShell command naming rules. If a module exports cmdlets or functions that have unapproved verbs in their names, the Import-Module cmdlet displays the following warning message:

WARNING: Some imported command names include unapproved verbs which might make them less discoverable. Use the Verbose parameter for more detail or type Get-Verb to see the list of approved verbs.

This message is only a warning. The complete module is still imported, including the non-conforming commands. Although the message is displayed to module users, the naming problem should be fixed by the module author.

To suppress the warning message, use the DisableNameChecking parameter of the Import-Module cmdlet.

See Also

Other Resources

about_Modules
Import-Module