Close pipe client handles after creating the child ssh process (#26491)

This commit is contained in:
Dongbo Wang
2025-11-24 20:05:03 +00:00
committed by GitHub
parent 70a6a80f6b
commit 9ee3c61c26
3 changed files with 41 additions and 22 deletions
@@ -70,3 +70,24 @@ Describe "SSHConnection parameter hashtable type conversions" -Tags 'Feature', '
$err.FullyQualifiedErrorId | Should -Match 'PSSessionOpenFailed'
}
}
Describe "No hangs when host doesn't exist" -Tags "CI" {
$testCases = @(
@{
Name = 'Verifies no hang for New-PSSession with non-existing host name'
ScriptBlock = { New-PSSession -HostName "test-notexist" -UserName "test" -ErrorAction Stop }
FullyQualifiedErrorId = 'PSSessionOpenFailed'
},
@{
Name = 'Verifies no hang for Invoke-Command with non-existing host name'
ScriptBlock = { Invoke-Command -HostName "test-notexist" -UserName "test" -ScriptBlock { 1 } -ErrorAction Stop }
FullyQualifiedErrorId = 'PSSessionStateBroken'
}
)
It "<Name>" -TestCases $testCases {
param ($ScriptBlock, $FullyQualifiedErrorId)
$ScriptBlock | Should -Throw -ErrorId $FullyQualifiedErrorId -ExceptionType 'System.Management.Automation.Remoting.PSRemotingTransportException'
}
}