Let’s suppose to start a process in a remote Powershell command prompt. This process prints output to the console:
PS local> $Session = New-PSSession -Credential $cred -ComputerName 192.168.0.135
PS local> Enter-PSSession $Session
[192.168.0.135]: PS remote> custom-process.exe
log1
log2
...
Then I close the powershell window.
Now I reopen a powershell window and reenter the remote session, then
PS local> $Session = New-PSSession -Credential $cred -ComputerName 192.168.0.135
PS local> Enter-PSSession $Session
[192.168.0.135]: PS remote>
I would expect to see all the logs that custom_process emitted, instead nothing. The proess is still running of course
[192.168.0.135]: PS remote> Get-Process
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName
------- ------ ----- ----- ------ -- -- -----------
67 5 880 4428 0.02 2860 0 ***
1490 92 94520 131600 4.02 6336 0 custom-process
What should I do to reconnect to the exact same session used to start custom-process and see the logs that the process emitted to the console?