I've successfully got winrm working and I'm able to run Enter-PSSession my-machine
in the shell and subsequently enter commands. However, when I try to run a script that starts up a remote session, all subsequent calls are run on the local machine. For instance:
PS> test.ps1
Contents of test.ps1
Enter-PSSession remote-pcname
gc env:computername
prints out local-pcname
instead of remote-pcname
any idea why the script file is not honoring the remote session? It is definitely successfully connecting because when the script finishes I'm returned to the shell prompt of the remote machine.