Contact Info

Crumbtrail

ActiveXperts.com » Administration » Powershell » Powershell 3.0 » Import-Module

Import-Module - Powershell 3.0 CmdLet

ActiveXperts Network Monitor ships with integrated Powershell scripts to monitor complex network. The scripts run out of the box
Download the ActiveXperts Network Monitor FREE version now »

Import-Module

Short description
Adds modules to the current session.

Syntax
Import-Module [-Name] <String[]> [-Alias <String[]>] [-ArgumentList <Object[]>] [-AsCustomObject] [-Cmdlet <String[]>] 
[-DisableNameChecking] [-Force] [-Function <String[]>] [-Global] [-MinimumVersion <Version>] [-NoClobber] [-PassThru] [
-Prefix <String>] [-RequiredVersion <Version>] [-Scope <String>] [-Variable <String[]>] [<CommonParameters>]
Import-Module [-Assembly] <Assembly[]> [-Alias <String[]>] [-ArgumentList <Object[]>] [-AsCustomObject] [-Cmdlet <Strin
g[]>] [-DisableNameChecking] [-Force] [-Function <String[]>] [-Global] [-NoClobber] [-PassThru] [-Prefix <String>] [-Sc
ope <String>] [-Variable <String[]>] [<CommonParameters>]
Import-Module [-Name] <String[]> [-Alias <String[]>] [-ArgumentList <Object[]>] [-AsCustomObject] [-CimNamespace <Strin
g>] [-CimResourceUri <Uri>] [-Cmdlet <String[]>] [-DisableNameChecking] [-Force] [-Function <String[]>] [-Global] [-Min
imumVersion <Version>] [-NoClobber] [-PassThru] [-Prefix <String>] [-RequiredVersion <Version>] [-Scope <String>] [-Var
iable <String[]>] -CimSession <CimSession> [<CommonParameters>]
Import-Module [-Name] <String[]> [-Alias <String[]>] [-ArgumentList <Object[]>] [-AsCustomObject] [-Cmdlet <String[]>] 
[-DisableNameChecking] [-Force] [-Function <String[]>] [-Global] [-MinimumVersion <Version>] [-NoClobber] [-PassThru] [
-Prefix <String>] [-RequiredVersion <Version>] [-Scope <String>] [-Variable <String[]>] -PSSession <PSSession> [<Common
Parameters>]
Import-Module [-ModuleInfo] <PSModuleInfo[]> [-Alias <String[]>] [-ArgumentList <Object[]>] [-AsCustomObject] [-Cmdlet 
<String[]>] [-DisableNameChecking] [-Force] [-Function <String[]>] [-Global] [-NoClobber] [-PassThru] [-Prefix <String>
] [-Scope <String>] [-Variable <String[]>] [<CommonParameters>]





Description
The Import-Module cmdlet adds one or more modules to the current session. The modules that you import must be installed
 on the local computer or a remote computer.


Beginning in Windows PowerShell 3.0, installed modules are automatically imported to the session when you use any comma
nds or providers in the module. However, you can still use the Import-Module command to import a module and you can ena
ble and disable automatic module importing by using the $PSModuleAutoloadingPreference preference variable. For more in
formation about modules, see about_Modules (http://go.microsoft.com/fwlink/?LinkID=144311). For more information about 
the $PSModuleAutoloadingPreference variable, see about_Preference_Variables (http://go.microsoft.com/fwlink/?LinkID=113
248).


A module is a package that contains members (such as cmdlets, providers, scripts, functions, variables, and other tools
 and files) that can be used in Windows PowerShell. After a module is imported, you can use the module members in your 
session.


To import a module, use the Name, Assembly,  ModuleInfo, MinimumVersion and RequiredVersion parameters to identify the 
module to import. By default, Import-Module imports all members that the module exports, but you can use the Alias, Fun
ction, Cmdlet, and Variable parameters to restrict the members that are imported. You can also use the NoClobber parame
ter to prevent Import-Module from importing members that have the same names as members in the current session.


Import-Module imports a module only into the current session. To import the module into all sessions, add an Import-Mod
ule command to your Windows PowerShell profile. For more information about profiles, see about_Profiles (http://go.micr
osoft.com/fwlink/?LinkID=113729).


Also, beginning in Windows PowerShell 3.0, you can use Import-Module to import Common Information Model (CIM) modules, 
in which the cmdlets are defined in Cmdlet Definition XML (CDXML) files. This feature allows you to use cmdlets that ar
e implemented in non-managed code assemblies, such as those written in C++.


With these new features, Import-Module cmdlet becomes a primary tool for managing heterogeneous enterprises that includ
e Windows computers and computers that are running other operating systems.


To manage remote Windows computers that have Windows PowerShell and Windows PowerShell remoting enabled, create a PSSes
sion on the remote computer and then use the PSSession parameter of Get-Module to get the Windows PowerShell modules in
 the PSSession. When you import the modules, and then use the imported commands in the current session, the commands ru
n implicitly in the PSSession on the remote computer. You can use this strategy to manage the remote computer.


You can use a similar strategy to manage computers that do not have Windows PowerShell remoting enabled, including comp
uters that are not running a Windows operating system, and Windows computers that have Windows PowerShell, but do not h
ave Windows PowerShell remoting enabled.


Begin by creating a "CIM session" on the remote computer; a connection to Windows Management Instrumentation (WMI) on t
he remote computer. Then use the CIMSession parameter of Import-Module to import CIM modules from the remote computer. 
When you import a CIM module and then run the imported commands, the commands run implicitly on the remote computer. Yo
u can use this WMI and CIM strategy to manage the remote computer.