Update ServerRemoteHost Version to be same as PSVersion (#15809)

This commit is contained in:
Steve Lee 2021-08-04 15:01:18 -07:00 committed by GitHub
parent aaaa0f2baa
commit 2ae0e4d9dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View file

@ -4,6 +4,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Management.Automation;
using System.Management.Automation.Host;
using System.Management.Automation.Internal;
using System.Management.Automation.Remoting;
@ -73,7 +74,7 @@ namespace System.Management.Automation
/// </summary>
internal static class RemotingConstants
{
internal static readonly Version HostVersion = new Version(1, 0, 0, 0);
internal static readonly Version HostVersion = PSVersionInfo.PSVersion;
internal static readonly Version ProtocolVersionWin7RC = new Version(2, 0);
internal static readonly Version ProtocolVersionWin7RTM = new Version(2, 1);

View file

@ -345,5 +345,16 @@ Describe "Remoting loopback tests" -Tags @('CI', 'RequireAdminOnWindows') {
$result = Invoke-Command -Session $openSession -ScriptBlock { $using:number }
$result | Should -Be 100
}
It '$Host.Version should be PSVersion' {
$session = New-RemoteSession -ConfigurationName $endPoint
try {
$result = Invoke-Command -Session $session -ScriptBlock { $Host.Version }
$result | Should -Be $PSVersionTable.PSVersion
}
finally {
$session | Remove-PSSession -ErrorAction Ignore
}
}
}