For remote work on a Linux server, I can ssh
and then tmux
to resume my work (including stdout/stderr).
How can I get the same experience on Windows server using Powershell? I have done some basic reading on Enter-PSSession
but that feels like ssh without tmux.
Type the following cmdlet and then hit Enter: "Restart-Service WinRM". It's time to test the connection, From the MID Server execute the following cmdlet into PowerShell and then hit Enter: "Test-WsMan <Target IP>" and This simple command tests whether the WinRM service is running on the remote Host.
With tmux you only need one SSH connection to the server. The great thing about tmux is it allows you to have multiple panes open at the same time, each with their own shell running, but using the same, single SSH connection.
When you use Enter-PSSession
and exit with Exit-PSSession
, The Session is Permanently deleted and you can't resume it.
However, You can Create a Remote Session like this:
$session = New-PSSession -ComputerName $ComputerName
And Then Connect into it
Enter-PSSession $session
This way You Can disconnect (but the session will remain connected)
Exit-PSSession
And Reconnect again (and come back to the same state)
Enter-PSSession $session
As long as $session
variable is available the session remains open and all your work remain in the same state
To Disconnect the Session:
Disconnect-PSSession $session
To remove the Session:
Remove-PSSession $session
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With