Contact Info

Crumbtrail

ActiveXperts.com » Administration » Powershell » Powershell 2.0 » Import-PSSession

Import-PSSession - Powershell 2.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-PSSession

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

Syntax
Import-PSSession [-Session] <PSSession> [[-CommandName] <string[]>] [[-FormatTypeName] <string[]>] [-AllowClobber] 
[-ArgumentList <Object[]>] [-CommandType {Alias | Function | Filter | Cmdlet | ExternalScript | Application | Scrip
t | All}] [-Module <string[]>] [-Prefix <string>] [<CommonParameters>]

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

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

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 n
ames 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, t
he imported part of the command runs implicitly in the session from which it was imported. However, the remote oper
ations are handled entirely by Windows PowerShell. You need not even be aware of them, except that you must keep th
e 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
 every imported command. This parameter allows you to run the command as a Windows PowerShell background job. For m
ore information, 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 i
n 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 compu
ter.