-
Notifications
You must be signed in to change notification settings - Fork 513
Add remoting docs #1162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
TylerLeonhardt
merged 6 commits into
PowerShell:master
from
TylerLeonhardt:remoting-doc
Jan 25, 2018
Merged
Add remoting docs #1162
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3004a08
add remoting md for 1.6.0 release
TylerLeonhardt 7f1c098
didn't know github urls are case-sensitive. asset -> Asset
TylerLeonhardt b805053
remove assets
TylerLeonhardt 18f304e
remove assets
TylerLeonhardt ec25ad4
Updated to Open-EditorFile
TylerLeonhardt 327c429
backcompat
TylerLeonhardt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# PowerShell Remote Editing and Debugging in VSCode | ||
|
||
For those of you that were familiar with the ISE, you may recall that you were able to use run `psedit file.ps1` from the integrated console to open files - local or remote - right in the ISE. | ||
|
||
As it turns out, this feature is also availible out of the box in the PowerShell extension for VSCode. This guide will show you how to do it. | ||
|
||
## Prerequisites | ||
|
||
This guide assumes that you have: | ||
|
||
* a remote resource (ex: a VM, a container) that you have access to | ||
* PowerShell running on it and the host machine | ||
* VSCode and the PowerShell extension for VSCode | ||
|
||
NOTE: | ||
|
||
This works on Windows PowerShell and the cross-platform version, [PowerShell Core](https://github.com/powershell/powershell). | ||
|
||
This also works when connecting to a remote machine via WinRM, PowerShell Direct, or SSH. If you want to use SSH, but are using Windows, check out the Win32 version of SSH [here](https://github.com/PowerShell/Win32-OpenSSH)! | ||
|
||
## Let's go | ||
|
||
In this section, I will walk through remote editing and debugging from my MacBook Pro, to an Ubuntu VM running in Azure. I might not be using Windows, but **the process is identical**. | ||
|
||
### Local file editing with psedit | ||
|
||
With the PowerShell extension for VSCode started and the PowerShell Integrated Console opened, we can type `psedit foo.ps1` to open the local foo.ps1 file right in the editor. | ||
|
||
 | ||
|
||
NOTE: foo.ps1 must already exist. | ||
|
||
From there, we can: | ||
|
||
add breakpoints to the gutter | ||
 | ||
|
||
and hit F5 to debug the PowerShell script. | ||
 | ||
|
||
While debugging, you can interact with the debug console, check out the variables in the scope on the left, and all the other standard debugging tools. | ||
|
||
### Remote file editing with psedit | ||
|
||
Now let's get into remote file editing and debugging. The steps are nearly the same, there's just one thing we need to do first - enter our PowerShell session to the remote server. | ||
|
||
There's a cmdlet for that. It's called `Enter-PSSession`. | ||
|
||
The watered down explaination of the cmdlet is: | ||
|
||
* `Enter-PSSession -ComputerName foo` starts a session via WinRM | ||
* `Enter-PSSession -ContainerId foo` and `Enter-PSSession -VmId foo` start a session via PowerShell Direct | ||
* `Enter-PSSession -HostName foo` starts a session via SSH | ||
|
||
For more info on `Enter-PSSession`, check out the docs [here](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/enter-pssession?view=powershell-6). | ||
|
||
Since I will be remoting from macOS to an Ubuntu VM in Azure, I will use SSH for this. | ||
|
||
First, in the Integrated Console, let's run our Enter-PSSession. You will know that you're in the session because `[something]` will show up to the left of your prompt. | ||
|
||
NOTE: I've blacked out the IP address. | ||
|
||
 | ||
|
||
From there, we can do the exact steps as if we were editing a local script. | ||
|
||
1. Run `psedit test.ps1` to open the remote `test.ps1` file | ||
 | ||
2. Edit the file/set breakpoints | ||
 | ||
3. Start debugging the remote file | ||
|
||
 | ||
|
||
That's all there is to it! We hope that this helped clear up any questions about remote debugging and editing PowerShell in VSCode. | ||
|
||
If you have any problems, feel free to open issues [on the GitHub repo](http://github.com/powershell/vscode-powershell). |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd mention the use of F5 again here just in case the skipped the previous section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed