Fix The handle is invalid
Microsoft Edit is installed on the Windows host, PowerShell finds edit.exe, and New-Item successfully creates myTest.txt. Yet running edit .\myTest.txt inside Enter-PSSession returns Error 0x80070006: The handle is invalid. This is confusing because the executable and file are both present. The failure is caused by the session type: a WinRM PowerShell remoting session does not provide the normal interactive console handles that a full-screen terminal editor expects. Quick answer Nothing in the screenshots indicates a broken Edit installation or a file permission problem. Edit does not work in the shown WinRM Enter-PSSession because PSRP does not provide the console handles its TUI needs. There is no setting, permission change, or reinstall that fixes this within that session type. Use a direct interactive SSH terminal with a PTY instead; the fifth screenshot confirms Edit works there. Enter-PSSession -HostName is still a PowerShell remoting session, not the direct SSH shell shown in the screenshot. ...