In the preceding example, Import-PSSession is used to immediately import commands from a remote system into a local session. Export-PSSession writes a persistent module that can be used to achieve the same goal.
The following example creates a module in the current user's module path:
$computerName = 'PSTest' $session = New-PSSession -ComputerName $computerName Export-PSSession -Session $session -Module NetAdapter -OutputModule "NetAdapter-$computerName"
Once the module has been created, it can be imported by name:
Import-Module "NetAdapter-$computerName"
This process replaces the need to define and import a session, and is useful for remote commands that are used on a regular basis.