Visual Studio - PowerShell Remoting

Welcome Forums General PowerShell Q&A Visual Studio - PowerShell Remoting

This topic contains 1 reply, has 2 voices, and was last updated by

 
Keymaster
6 months, 3 weeks ago.

  • Author
    Posts
  • #97490

    Participant

    I am testing Visual Studio Community and Visual Studio Code with powershell extensions and having some issues in regard to remoting when it comes to the editor.

    In PowershellISE, when I initiate a remote session, for example:

    Enter-PSSession -ComputerName w12-tp -Credential tp\administrator

    Anything I run from the PS ISE editor runs in that remote session.

    However, when I launch the command in VSCode or Visual studio community after I have initiated that same remote session, I receive this error in the output window, which seems that it is trying to take the path of my script and mirror it on the remote server:

    [w12-tp] PS C:\Users\administrator.TP\Documents> C:\Users\bclanton\Google Drive\Code\Projects\PowerShellProject1\PowerShellProject1\PowerShellProject1.ps1
    Local script (C:\Users\bclanton\Google Drive\Code\Projects\PowerShellProject1\PowerShellProject1\PowerShellProject1.ps1) cannot be run through remote PowerShell session
    The program 'PowerShellProject1.ps1: PowerShell Script' has exited with code 0 (0x0).

    Has anyone had experience with this and know if there is a setting I need to adjust to allow for running code in the editor on my remote session?

  • #97493

    Keymaster

    The ISE maintains a persistent connection because of the way it handles scope; VS Code doesn't – which is actually more proper for a development environment. Enter-PSSession is for interactive use, and VS Code is for developing scripts. I don't believe the PowerShell extension currently supports what you're trying to do.

The topic ‘Visual Studio - PowerShell Remoting’ is closed to new replies.