Contact Info

Crumbtrail » Administration » Powershell » Powershell 3.0 » Import-PSSession

Import-PSSession - 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 »


Short description
Imports commands from another session into the current session.

Import-PSSession [-Session] <PSSession> [[-CommandName] <String[]>] [[-FormatTypeName] <String[]>] [-AllowClobber] [-Ar
gumentList <Object[]>] [-Certificate <X509Certificate2>] [-CommandType <CommandTypes>] [-DisableNameChecking] [-Module 
<String[]>] [-Prefix <String>] [<CommonParameters>]

The Import-PSSession cmdlet imports commands (such as cmdlets, functions, and aliases) from a PSSession on a local or r
emote computer into the current session. You can import any command that the Get-Command cmdlet can find in the PSSessi

Use an Import-PSSession command to import commands from a customized shell, such as a Microsoft Exchange Server shell, 
or from a session that includes Windows PowerShell modules and snap-ins or other elements that are not in the current s

To import commands, first use the New-PSSession cmdlet to create a PSSession. Then, use the Import-PSSession cmdlet to 
import the commands. By default, Import-PSSession imports all commands except for commands that have the same names as 
commands in the current session. To import all the commands, use the AllowClobber parameter.

You can use imported commands just as you would use any command in the session. When you use an imported command, the i
mported part of the command runs implicitly in the session from which it was imported. However, the remote operations a
re handled entirely by Windows PowerShell. You need not even be aware of them, except that you must keep the connection
 to the other session (PSSession) open. If you close it, the imported commands are no longer available.

Because imported commands might take longer to run than local commands, Import-PSSession adds an AsJob parameter to eve
ry imported command. This parameter allows you to run the command as a Windows PowerShell background job. For more info
rmation, see about_Jobs.

When you use Import-PSSession, Windows PowerShell adds the imported commands to a temporary module that exists only in 
your session and returns an object that represents the module. To create a persistent module that you can use in future
 sessions, use the Export-PSSession cmdlet.

The Import-PSSession cmdlet uses the implicit remoting feature of Windows PowerShell. When you import commands into the
 current session, they run implicitly in the original session or in a  similar session on the originating computer.

Beginning in Windows PowerShell 3.0, you can use the Import-Module cmdlet to import modules from a remote session into 
the current session. This feature uses implicit remoting. It is equivalent to using Import-PSSession to import selected
 modules from a remote session into the current session.