title: Enter-PSSession is not working in my Powershell script
body: <p>When I run the lines below from a script the file ends up being created on my local machine.</p>
  
  <pre><code>$cred = Get-Credential domain\DanTest
  Enter-PSSession -computerName xsappb01 -credential $cred
  
  New-Item -type file c:\temp\blahxsappk02.txt
  
  exit-pssession
  </code></pre>
  
  <p>When I run each line individually from the powershell console the remote session is created correctly and the file is created on the remote machine.  Any thoughts on why?  Is it a timing issue is the script perhaps?</p>