Retrieving all output from remote session with Invoke-Command. RRS feed

  • Question

  • If I remotely invoke the following Powershell script:




    With something like this:

    $s = New-PSSession -ComputerName  mycomputer
    $result=Invoke-Command -Session $s -Script  { d:\go.ps1 }  

    I only get the error message for the division by zero.   The "Starting..." message is lost.

    How can I retrieve all of the output from the remote command in the event of an error?   

    Monday, October 16, 2017 2:45 PM

All replies

  • $result=Invoke-Command  -File d:\go.ps1


    $result=Invoke-Command -Script  {"Starting..."; 1/0}  


    Monday, October 16, 2017 2:52 PM