Skip to content

Invoke-Command aborts after 10 minutes (reopening #26176) #26369

@JohnnyDoesStuff

Description

@JohnnyDoesStuff

Prerequisites

Steps to reproduce

  1. Create a Hyper-V VM with a current version of Windows 11 (No network adapter needs to be connected)
  2. Install PowerShell 7.5.3 or later on the host
  3. Install PowerShell 7.5.3 or later in that VM.
  4. In the VM open an elevated pwsh and execute Enable-PSRemoting -SkipNetworkProfileCheck
  5. On the host run this command:
    $PSDefaultParameterValues."Invoke-Command:ConfigurationName" = "PowerShell.7"
    Invoke-Command -VMName MyTestVMName -Credential Developer -Command {
        while($true) {
            Get-Date
            Start-Sleep -Seconds 10
        }
    }
  6. Wait for 10 minutes

Expected behavior

The Invoke-Command still continues until we manually abort it

Actual behavior

After 10 minutes, the command ends with this error message: 

OpenError: [MyTestVMName] The background process reported an error with the following message: "The Hyper-V socket target process has ended."

Error details

Exception             :
    Type        : System.Management.Automation.Remoting.PSRemotingTransportException
    ErrorCode   : 2100
    ErrorRecord :
        Exception             :
            Type    : System.Management.Automation.ParentContainsErrorRecordException
            Message : The background process reported an error with the following message: "The
Hyper-V socket target process has ended.".
            HResult : -2146233087
        CategoryInfo          : ResourceUnavailable: (:) [], ParentContainsErrorRecordException
        FullyQualifiedErrorId :
System.Management.Automation.Remoting.PSRemotingDataStructureException
    Message     : The background process reported an error with the following message: "The Hyper-V
socket target process has ended.".
    HResult     : -2146233087
TargetObject          : MyTestVMName
CategoryInfo          : OpenError: (TestVM_3bd5e6b2-09e…8-9527-338d91126c3a:String) [],
PSRemotingTransportException
FullyQualifiedErrorId : 2100,PSSessionStateBroken
ErrorDetails          : [MyTestVMName] The background process
reported an error with the following message: "The Hyper-V socket target process has ended.".

Environment data

Name                           Value
----                           -----
PSVersion                      7.5.3
PSEdition                      Core
GitCommitId                    7.5.3
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

Since PowerShell 7.5.3 we are experiencing an issue when executing long-running commands in Hyper-V VMs. After pretty exactly 10 minutes of usage the connection gets closed. It only happens if it is a single Invoke-Command that takes that much time. Running many short Invoke-Commands with the same session does not lead to this behaviour.

We are doing this on managed Windows 11 office computers. For some time on a few clients the issue did not seem to occur but now does as well. When rolling back to PowerShell 7.5.2 we don't see this issue anymore. With all of these versions, the error was reproducable for me:

  • 7.5.3
  • 7.5.4
  • 7.6.0.preview 5
  • Windows PowerShell 5.1

Due to the comments in the previous issue (#26176) and these observations, i assume that something in Windows got bugged by an update but that PowerShell 7.5.2 had some way to still work.

Metadata

Metadata

Assignees

Labels

Needs-TriageThe issue is new and needs to be triaged by a work group.Resolution-AnsweredThe question is answered.Resolution-ExternalThe issue is caused by external component(s).

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions