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?