powershell - Foreground job from invoke-command -asjob -
"Let’s say I have a really long job that I start with invoke-command as follows: $s = New-PSSession -Computer mycomp
Invoke-command -session $s -file myprofile.ps1
$j = invoke-command -asjob -Session $s -File ./reallylongtime.ps1
Wait-job $j Receive-job $j
Is there a way to reattach the job $j as a foreground job and watch its terminal output in real-time? Currently, I’m waiting for the job to finish and then outputting the job terminal output all at once with receive-job. Also, I don’t want to just call “invoke-command -computer” I need this to work with new-pssession instead.
powershell
ShareShare a link to this question Copy linkCC BY-SA 4.0
Follow Follow this question to receive notifications
edited 1 min ago pico
asked 6 mins ago picopico 96577 silver badges2626 bronze badges"
|