title: PowerShell using an existing session state to fill in InitialSessionState
body: <p>I am trying to call\create runspace within a class that derived from PSCmdlet. Since PSCmdlet includes a default session state that contains shared data I want to reuse in the runspace, I am wondering if there is a programmatically way to convert the current sessionState into the runspace's InitialSessionState ?</p>
  
  <p>If there is no such way, I am not really understand why such session state info cannot be shared within different runspace. This looks like running a remote runspace to me. Can anyone explain?</p>
  
  <p>For example,</p>
  
  <pre><code>namespace CustomCmdlet.Test
  {
      [Cmdlet("Get", "Test1")]
      public class GetTest1 : PSCmdlet
      {
          protected override void ProcessRecord()
          { WriteObject("1"); }
      }
  
      [Cmdlet("Get", "Test2")]
      public class GetTest2 : PSCmdlet
      {
          protected override void ProcessRecord()
          {
           // instead of import the module dll using Runspace
           // InitialSessionState.ImportModule(new string[] {"CustomCmdlet.Test.dll"});
           // Runspace runspace = RunspaceFactory.CreateRunspace(InitialSessionState)
  
           // is it any way to import the PSCmdlet.SessionState into the InitialSessionState?
          }
      }
  </code></pre>
  
  <p>We are using PowerShell 4.0, if this is relevant. </p>