Using Modules and Snap-Ins

Updated: August 9, 2012

Applies To: Windows PowerShell 2.0, Windows PowerShell 3.0

Windows PowerShell is a fully extensible environment. Anyone can write cmdlets for Windows PowerShell. You can use cmdlets that others write and share the cmdlets that you write with others.

Cmdlets are shared by using modules and snap-ins. Windows PowerShell modules and snap-ins are packages that contain Windows PowerShell cmdlets and other items. All cmdlets and providers in Windows PowerShell are delivered in snap-ins or modules, and modules can also contain other Windows PowerShell tools, such as functions, aliases, variables, and drives.

Some snap-ins and modules are added automatically to every Windows PowerShell session. If you receive a snap-in or module, you can install it and add the cmdlets to your Windows PowerShell sessions. To share the cmdlets that you write, you can create a Windows PowerShell module or snap-in.

About Modules

A module is a package of cmdlets and other items that you can use in Windows PowerShell. After you run the module setup program or save the module to disk, you can use the cmdlets and items in the module. You can also use modules to organize the cmdlets, providers, functions, aliases, and other cmdlets that you create, and share them with others.

For detailed information about installing and using modules, including step-by-step instructions and example, see about_Modules. For information about creating modules, see Writing a Windows PowerShell Module in MSDN.

Importing Modules

When you "import" a module, Windows PowerShell adds the cmdlets, providers, and other tools in the module to your current session so you can use them. The module might also add files that format output so it's easy to read and run scripts in the session to customize the environment.

Beginning in Windows PowerShell 3.0, modules are imported into the session automatically the first time you use a cmdlet in the module. As a result, you just find the command you need and use it. Windows PowerShell takes care of the importing. However, if you prefer, you can use the Import-Module cmdlet to import a module at any time.

About Snap-ins

A Windows PowerShell snap-in (PSSnapin) is a dynamic link library (.dll) that implements cmdlets and providers. When you receive a snap-in, you need to install it, and then you can add the cmdlets and providers in the snap-in to your Windows PowerShell session.

For information about installing and using snap-ins, see about_PSSnapins. For information about writing snap-ins, see How to Create a Windows PowerShell Snap-in in MSDN.