Categories

PowerShell remoting options

One of the big pieces of functionality in PowerShell v2 is the ability to directly administer remote machines.  A number of cmdlets get a computername parameter for working directly. The main push for remoting is through the *-PSsession cmdlets

Enter-PSSession
Exit-PSSession
Export-PSSession
Get-PSSession
Import-PSSession
New-PSSession
Remove-PSSession

New-, Get and Remove- I have blogged about before.  The interesting ones are the Enter/Exit and Import/Export pairs.

Enter-PSsession enables you to work directly in the session – as if you had RDP’d into the machine and were running PowerShell on the box.  It means we don’t need to use Invoke-Command as much. Exit-PSsession steps back out of the session but leaves the session open.

Import-PSsession enables you to import functionality from the remote session into your local PowerShell session.  For instance you can import the 2008 R2 AD cmdlets into your local session.  They show up as functions rather than cmdlets but are fully usable.

Export-PSsession saves PowerShell command types (cmdlets, functions etc) to a module that can be loaded at any time into a session.

There is a lot of flexibility and power built into the remoting system that should allow you to get a way of working that suits you.

Technorati Tags: ,,

Leave a Reply