title: Reusing/Sharing of powershell remote sessions accross scripts
body: <p>I have a php server that generates a ps1(poweshell) script and manage remote computer. For example I have powershell script that looks like:</p>
  
  <pre><code>$ip=192.168.137.25;
  $pw = convertto-securestring -AsPlainText -Force -String a
  $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist "$ip\admin",$pw
   $session = new-pssession $ip -credential $cred
  invoke-command -session $session -scriptblock {ls}
  </code></pre>
  
  <p>I run this script from php by:</p>
  
  <pre><code>shell_exec("powershell.exe -ExecutionPolicy RemoteSigned -File script.ps1")
  </code></pre>
  
  <p>Then I need to invoke second script, and want to use session created by first script. 
  The question is how to leave remote session alive after first script ending.
  Maybe is there other solutions like using other languages instead of php?</p>
  
  <p>Thanks</p>