Any way to view local console windows of PSRemote job?

I have a script that will launch a PSRemote job using the command below:

$NewJob = Invoke-Command -ComputerName $Job.ComputerName -AsJob -Credential $Credential -ArgumentList $Credential,$ModuleCode,$ArgumentList,$WhatIfPreference,$VerbosePreference -ScriptBlock $RemoteScriptBlock

The scriptblock contains code that will launch a RoboCopy job with the WindowStyle set to Normal. When running the same scriptblock as a local job, it works as expected.

When such a PSRemote job is running, and something appears to be wrong, I have attempted to log in to the remote machine using the same credentials used to launch the job originally. However, I cannot see the RoboCopy window, or the PowerShell script window. Is there a way to make these visible? I am generating RoboCopy logs and also using Receive-Job to get the console output sent back to the originating console, but I’m not getting the info I need to see what’s wrong. I’ve tried grabbing the PID of the RoboCopy job and setting the WindowStyle to normal, but that didn’t appear to have any effect. Am I trying to do something that is not possible?


If you are generating robocopy logs then you should see the problem in there if it is a robocopy error. Check your PowerShell event logs on the remote system. You may see the problem there. But you may need to enable more detailed logging. See about_Windows_Logging for more information.

If you are logging your robo to a file, I trust you are also using /TEE, otherwise, nothing goes to Stdout, just the log file.

PowerShell remoting cannot handle process interactively, hence you wont be able to see the window, but of-course the process like robocopy will run. If you are having proper error handling, Receive-Job should show the errors occurred during the execution. Otherwise I suggest you to use Transcribing using Start-Transcript cmdlet in you scriptblock which will record everything written to the host using Write-Host.

Don’t run it as a job?