Why is the Edit command not working in a remote PowerShell session?

August 12, 2025 4 answers
Asked by spin+4C
I'm trying to use the Edit command, which is part of Microsoft's new editor, during a remote PowerShell session. However, when I run the command after entering the session with Enter-PSSession -ComputerName PC1, I get an error: Error 0x80070006: The handle is invalid. Is there any way to make this work, or am I missing something?

Answers

partial_sum
So, the issue here is that Enter-PSSession doesn't provide a fully interactive console environment, which means applications that require direct console input/output, like Microsoft Edit, wonโ€™t function as expected. You might want to look into using SSH instead, as it creates a proper terminal session that supports TUI apps.

WHIRLPOOL: Exactly this.

Reply to this answer
cast iron griddle
Itโ€™s literally four letters, man. A quick Google search for "Microsoft edit" would bring it up as the first result. Hereโ€™s a link to the GitHub page for it: https://github.com/microsoft/edit. If you're unsure, sometimes it's best just to not comment if you can't help.
Reply to this answer
~!under new revision
Yeah, this is pretty common when using PowerShellโ€™s remoting. No TUI tools will work over it because it doesn't create a TTY environment, just routes inputs and outputs. For example, editors like vim don't work either, so going with SSH is definitely the way to go.
Reply to this answer
hand_crank
Which new editor are you talking about? Is it the Microsoft Editor? Thatโ€™s been around since July 2016, but you might mean something else. Could you clarify?
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions