Enter-PSSession – Do’s and Dont’s

by Nov 15, 2010

Enter-PSSession will let you switch your console input to a remote computer—if remoting is enabled on the target computer. Essentially, anything you enter after Enter-PSSession is sent to the remote computer that you specified with -ComputerName, and any result is marshaled back to your console. This, of course, requires PowerShell Remoting to be setup appropriately on the target machine.

However, you should be aware that Enter-PSSession only sends your interactive commands to the remote machine. So, it does not make sense to pre-pend script code with Enter-PSSession to run your script remotely. The script will not run remotely this way. Instead, it will run on your local machine. Instead, you should use Invoke-Command -ComputerName XYZ -FilePath c:\myscript.ps1 to run scripts remotely.

Twitter This Tip!
ReTweet this Tip!