Any way to view local console windows of PSRemote job?

Welcome Forums General PowerShell Q&A Any way to view local console windows of PSRemote job?

Viewing 4 reply threads
  • Author
    Posts
    • #184727
      Participant
      Topics: 1
      Replies: 0
      Points: -6
      Rank: Member

      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?

       

    • #186356
      Participant
      Topics: 0
      Replies: 21
      Points: 136
      Helping Hand
      Rank: Participant

      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.

    • #188407
      Participant
      Topics: 0
      Replies: 5
      Points: 7
      Rank: Member

      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.

    • #188422
      Senior Moderator
      Topics: 8
      Replies: 1141
      Points: 3,927
      Helping Hand
      Rank: Community Hero

      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.

    • #188443
      js
      Participant
      Topics: 27
      Replies: 716
      Points: 1,881
      Helping Hand
      Rank: Community Hero

      Don't run it as a job?

Viewing 4 reply threads
  • You must be logged in to reply to this topic.