When I run the lines below from a script the file ends up being created on my local machine.
$cred = Get-Credential domainDanTest
Enter-PSSession -computerName xsappb01 -credential $cred
New-Item -type file c:emplahxsappk02.txt
exit-pssession
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?
question from:https://stackoverflow.com/questions/3705321/enter-pssession-is-not-working-in-my-powershell-script