MID Server pre-upgrade check fails with PSReadLine/PSConsoleReadLine/WinIOError errorDescriptionMID Server pre-upgrade PowerShell check fails with PSReadLine/PSConsoleReadLine/WinIOError error, preventing the upgrade happening. The error starts with:Oops, something went wrong. Please report this bug with the details below.resulting in:Aborting MID Server upgrade due to pre-upgrade check failure Unfortunately the known Microsoft bug in PSReadLine module doesn't throw any exception. It just adds the error message to the output, which breaks the code that parses the output as part of detecting Powershell.https://github.com/PowerShell/PSReadLine/issues/1390PSReadline 2.0.0 does not work on PS 5.1 Windows 2012R2 serversSteps to Reproduce Install a MID Server on a windows server host that is subject to the PSReadLine bug. e.g. PowerShell 5.1 on Windows 2012R2 servers, but without .NET 4.6.1.Upgrade it The pre-upgrade check will fail with something like this in the MID Server agent log: 07/21/19 21:35:27 (215) AutoUpgrade.3600 WARNING *** WARNING *** no context : null07/21/19 21:35:27 (887) AutoUpgrade.3600 WARNING *** WARNING *** Unable to parse PowerShell PIDOops, something went wrong. Please report this bug with the details below.Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new-----------------------------------------------------------------------Last 0 Keys:Exception:System.IO.IOException: The handle is invalid.at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)at System.Console.GetBufferInfo(Boolean throwOnNoConsole, Boolean& succeeded)at Microsoft.PowerShell.Internal.ConhostConsole.get_CursorLeft()at Microsoft.PowerShell.PSConsoleReadLine.Initialize(Runspace runspace, EngineIntrinsics engineIntrinsics)at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)-----------------------------------------------------------------------Oops, something went wrong. Please report this bug with the details below.Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new-----------------------------------------------------------------------Last 0 Keys:Exception:System.IO.IOException: The handle is invalid.at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)at System.Console.GetBufferInfo(Boolean throwOnNoConsole, Boolean& succeeded)at Microsoft.PowerShell.Internal.ConhostConsole.get_CursorLeft()at Microsoft.PowerShell.PSConsoleReadLine.Initialize(Runspace runspace, EngineIntrinsics engineIntrinsics)at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)-----------------------------------------------------------------------SNC_PowerShell_PID=4304Oops, something went wrong. Please report this bug with the details below.Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new-----------------------------------------------------------------------Last 0 Keys:Exception:System.IO.IOException: The handle is invalid.at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)at System.Console.GetBufferInfo(Boolean throwOnNoConsole, Boolean& succeeded)at Microsoft.PowerShell.Internal.ConhostConsole.get_CursorLeft()at Microsoft.PowerShell.PSConsoleReadLine.Initialize(Runspace runspace, EngineIntrinsics engineIntrinsics)at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)----------------------------------------------------------------------- 07/21/19 21:35:37 (481) AutoUpgrade.3600 Result of PowerShell test:Oops, something went wrong. Please report this bug with the details below.Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new-----------------------------------------------------------------------Last 0 Keys:Exception:System.IO.IOException: The handle is invalid.at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)at System.Console.GetBufferInfo(Boolean throwOnNoConsole, Boolean& succeeded)at Microsoft.PowerShell.Internal.ConhostConsole.get_CursorLeft()at Microsoft.PowerShell.PSConsoleReadLine.Initialize(Runspace runspace, EngineIntrinsics engineIntrinsics)at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)-----------------------------------------------------------------------Oops, something went wrong. Please report this bug with the details below.Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new-----------------------------------------------------------------------Last 0 Keys:Exception:System.IO.IOException: The handle is invalid.at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)at System.Console.GetBufferInfo(Boolean throwOnNoConsole, Boolean& succeeded)at Microsoft.PowerShell.Internal.ConhostConsole.get_CursorLeft()at Microsoft.PowerShell.PSConsoleReadLine.Initialize(Runspace runspace, EngineIntrinsics engineIntrinsics)at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)-----------------------------------------------------------------------trueService running as LocalSystemOops, something went wrong. Please report this bug with the details below.Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new-----------------------------------------------------------------------Last 0 Keys:Exception:System.IO.IOException: The handle is invalid.at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)at System.Console.GetBufferInfo(Boolean throwOnNoConsole, Boolean& succeeded)at Microsoft.PowerShell.Internal.ConhostConsole.get_CursorLeft()at Microsoft.PowerShell.PSConsoleReadLine.Initialize(Runspace runspace, EngineIntrinsics engineIntrinsics)at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)----------------------------------------------------------------------- 07/21/19 21:35:37 (606) AutoUpgrade.3600 SEVERE *** ERROR *** Aborting MID Server upgrade due to pre-upgrade check failure: Oops, something went wrong. Please report this bug with the details below.WorkaroundThis problem is currently under review. You can contact ServiceNow Technical Support or subscribe to this Known Error article by clicking the Subscribe button at the top right of this form to be notified when more information will become available. Although this is not a problem with Servicenow code, checks may be added to avoid this breaking critical functions. Workarounds to avoid the Microsoft bug are in:KB0827229 MID Server Startup/Upgrade and Discovery/Orchestration Probes fail due to Microsoft Powershell PSReadLine bug - "Oops, something went wrong" "System.IO.IOException"Related Problem: PRB1437409