diff --git a/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs b/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs
index 9fb08064270..652ed1f9fa7 100644
--- a/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs
+++ b/src/System.Management.Automation/engine/remoting/fanin/OutOfProcTransportManager.cs
@@ -708,8 +708,32 @@ protected void OnExited(object sender, EventArgs e)
//
stdInWriter.StopWriting();
}
- PSRemotingTransportException psrte = new PSRemotingTransportException(PSRemotingErrorId.IPCServerProcessExited,
- RemotingErrorIdStrings.IPCServerProcessExited);
+
+ // Try to get details about why the process exited
+ // and if they're not available, give information as to why
+ string processDiagnosticMessage;
+ try
+ {
+ var jobProcess = (Process)sender;
+ processDiagnosticMessage = StringUtil.Format(
+ RemotingErrorIdStrings.ProcessExitInfo,
+ jobProcess.ExitCode,
+ jobProcess.StandardOutput.ReadToEnd(),
+ jobProcess.StandardError.ReadToEnd());
+ }
+ catch (Exception exception)
+ {
+ processDiagnosticMessage = StringUtil.Format(
+ RemotingErrorIdStrings.ProcessInfoNotRecoverable,
+ exception.Message);
+ }
+
+ string exitErrorMsg = StringUtil.Format(
+ RemotingErrorIdStrings.IPCServerProcessExited,
+ processDiagnosticMessage);
+ var psrte = new PSRemotingTransportException(
+ PSRemotingErrorId.IPCServerProcessExited,
+ exitErrorMsg);
RaiseErrorHandler(new TransportErrorOccuredEventArgs(psrte, transportMethod));
}
diff --git a/src/System.Management.Automation/resources/RemotingErrorIdStrings.resx b/src/System.Management.Automation/resources/RemotingErrorIdStrings.resx
index 4d88df7d036..981e28c6972 100644
--- a/src/System.Management.Automation/resources/RemotingErrorIdStrings.resx
+++ b/src/System.Management.Automation/resources/RemotingErrorIdStrings.resx
@@ -794,7 +794,7 @@ Do you want to continue?
The background process reported an error with the following message: {0}.
- The background process closed or ended abnormally.
+ The background process closed or ended abnormally: {0}.
There is an error processing data from the background process. Error reported: {0}.
@@ -1657,4 +1657,14 @@ All WinRM sessions connected to PowerShell session configurations, such as Micro
This parameter set requires WSMan, and no supported WSMan client library was found. WSMan is either not installed or unavailable for this system.
+
+
+ Exit code: {0}
+ Stdout: '{1}'
+ Stderr: '{2}'
+
+
+
+ Information about the process could not be read: '{0}'.
+