title: How to import custom PowerShell module into the remote session?
body: <p>I'm developing a custom PowerShell module, which I'd like to use in context of a remote session to a different computer. The following code (which obviously doesn't work) explains what I'm trying to achieve:</p>
  
  <pre><code>import-module .\MyCustomModule.psm1
  $session = new-pssession -computerName server01
  invoke-command -session $session -scriptblock { 
    &lt;# use function defined in MyCustomModule here #&gt; 
  }
  </code></pre>
  
  <p><strong>The first question is whether it is at all possible to achieve this scenario?</strong> I mean I would only like my custom module to be physically present on my machine, not on remote server. </p>
  
  <p>I have found <a href="https://stackoverflow.com/questions/2830827/powershell-remoting-using-imported-module-cmdlets-in-a-remote-pssession">this thread</a>, but I didn't manage it to work - it doesn't allow creating a session from remote machine back to the local one. Probably, I faced with the configuration limitations mentioned somewhere in the comments to that thread... Besides, the author mentioned the performance implications which is critical for my solution...</p>
  
  <p>If that's possible, then how?</p>
  
  <p>The version of PowerShell is currently not a constraint - if the solution is only available in PS 3.0 - I can live with this.</p>