Powershell Remoting: using imported module cmdlets in a remote pssession

Posted by Joanthan Matheus on Stack Overflow See other posts from Stack Overflow or by Joanthan Matheus
Published on 2010-05-13T22:50:35Z Indexed on 2010/05/13 22:54 UTC
Read the original article Hit count: 401

Is there a way to use modules that were imported in a local session in a remote session? I looked at import-pssession, but I don't know how to get the local session. Here's a sample of what I want to do.

import-module .\MyModule\MyModule.ps1
$session = new-pssession -computerName RemoteComputer
invoke-command -session $session -scriptblock { Use-CmdletFromMyModule }

Also, I do not want to import-module in the remote session, as the ps1 files are not on that server.

© Stack Overflow or respective owner

Related posts about powershell-v2.0

Related posts about remoting