MicrosoftDocs / PowerShell-Docs

The official PowerShell documentation sources
https://learn.microsoft.com/powershell
Other
1.96k stars 1.56k forks source link

Can't find either psedit or Open-EditorFile in remote session #4385

Closed yobyot closed 5 years ago

yobyot commented 5 years ago

Hello,

This would be cool if I could get it to work. Is there something "missing" at the remoted machine (an Ubuntu VM in Azure, very much like what the illustrations show.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

yobyot commented 5 years ago

Here's an image:

image

sdwheeler commented 5 years ago

PSEdit only exists inside of the PowerShell ISE or VS Code.

yobyot commented 5 years ago

Thanks. I cropped the image -- but if you look closely at the image, at the top you can see the errors are coming from a terminal session inside vscode. The terminal's options are shown at the top of the screen.

yobyot commented 5 years ago

@sdwheeler Please reopen this. It's not the user error you think it is.

sdwheeler commented 5 years ago

Then this is not a doc bug, it is an issue with VS Code. Please file an issue at https://github.com/PowerShell/vscode-powershell/issues.

/cc: @TylerLeonhardt

yobyot commented 5 years ago

Except that the doc is wrong, since it doesn't work.

sdwheeler commented 5 years ago

It is supposed to work.

If the feature was removed then this is a doc bug. Waiting for response from @TylerLeonhardt.

TylerLeonhardt commented 5 years ago

@yobyot, psedit only exists in the PowerShell Integrated Console which is the console provided by the, PowerShell extension. From your screenshot, you are using a regular PowerShell console in vscode which does not have psedit available.

yobyot commented 5 years ago

@TylerLeonhardt Thanks.

yobyot commented 5 years ago

@sdwheeler Doc should be updated, IMO, to reflect the fact that you must use the integrated console.

doctordns commented 5 years ago

PSEdit is a function that exists in the ISE by default. You can replicate this by adding this function definition into the Windows PowerShell Console's $profile:

Function PSEDIT {
[CmdletBInding()]
param([Parameter(Mandatory=$true)]$filenames)
foreach ($filename in $filenames) {
dir $filename | 
  where {!$_.PSIsContainer} |
     %{
        start-process $Pshome\powershell_Ise.exe $filename
      }
   }
}

This does not work with PowerShell 7, but with PowerShell 7, you would be using VS Code. You can always just type Code $filename and it just works! Another reason I like VS Code.

joeyaiello commented 5 years ago

Per conversation with @sdwheeler, there's no way for the non-Integrated Console to be enlightened in VS Code to support psedit (it reports as an xterm terminal). To that end, we should doc that behavior and suggest usage of code as doctordns pointed out. (That usage of code would work the same as in any non-Code-hosted terminal

yobyot commented 5 years ago

I think the simpler answer is: doc that psedit must be run in the integrated terminal provided by the PowerShell extension of vscode. That's the doc error, IMHO.

TylerLeonhardt commented 5 years ago

Yes, @sdwheeler please go with @yobyot's suggestion. psedit does more than what code does because it works on remote machines that you've Enter-PSSession'd into from the PowerShell Integrated Console.