From 9efb1ef4e8fbaa1a7b7adccdb4c0bb675b00a221 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Thu, 28 Jun 2018 11:46:12 -0700 Subject: [PATCH 1/7] remove `v` from version and use 6-Preview if running preview build --- .../engine/remoting/commands/CustomShellCommands.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs index 51a7c940f62..0c88830cfbe 100644 --- a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs +++ b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs @@ -1519,7 +1519,12 @@ internal static string GetWinrmPluginShellName() // PowerShell Core uses a versioned directory to hold the plugin // TODO: This should be PSVersionInfo.PSVersionName once we get // closer to release. Right now it doesn't support alpha versions. - return System.String.Concat("PowerShell.", PSVersionInfo.GitCommitId); + string version = PSVersionInfo.GitCommitId; + if (version.StartsWith("v")) + { + version = version.Substring(1, version.Length - 1); + } + return System.String.Concat("PowerShell.", version); } /// @@ -4889,6 +4894,10 @@ function Enable-PSRemoting if ($dotPos -ne -1) {{ $powershellVersionMajor = $powershellVersionMajor.Substring(0, $dotPos) }} + if ($PSVersionTable.PSVersion.ToString().Contains(""preview"")) + {{ + $powershellVersionMajor += ""-Preview"" + }} Register-EndpointIfNotPresent -Name (""PowerShell."" + $powershellVersionMajor) $Force $queryForRegisterDefault $captionForRegisterDefault # PowerShell Workflow and WOW are not supported for PowerShell Core From 7a0aaef0fd9e94d3dc3e92c8bd1de6fc49749d40 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Thu, 28 Jun 2018 14:08:10 -0700 Subject: [PATCH 2/7] fix tests to match code change --- .../remoting/commands/CustomShellCommands.cs | 1 + .../PSSessionConfiguration.Tests.ps1 | 23 ++++++------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs index 0c88830cfbe..bba86b0acb1 100644 --- a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs +++ b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs @@ -1524,6 +1524,7 @@ internal static string GetWinrmPluginShellName() { version = version.Substring(1, version.Length - 1); } + return System.String.Concat("PowerShell.", version); } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 index beb597f9f3e..102405d0f66 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 @@ -17,7 +17,7 @@ try # if ($IsNotSkipped) { - $endpointName = "PowerShell.$($psversiontable.GitCommitId)" + $endpointName = "PowerShell.$($psversiontable.GitCommitId)".Replace("PowerShell.v","PowerShell.") $matchedEndpoint = Get-PSSessionConfiguration $endpointName -ErrorAction SilentlyContinue @@ -426,18 +426,13 @@ namespace PowershellTestConfigNamespace "@ $script:SourceFile = join-path $script:TestAssemblyDir "PowershellTestConfig.cs" $PscConfigDef | out-file $script:SourceFile -Encoding ascii -Force - $TestAssemblyName = "TestAssembly.dll" + $TestAssemblyName = "TestAssembly" + (New-Guid) + ".dll" $TestAssemblyPath = join-path $script:TestAssemblyDir $TestAssemblyName Add-Type -path $script:SourceFile -OutputAssembly $TestAssemblyPath return $TestAssemblyName } $script:TestDir = join-path $TestDrive "Remoting" - if(-not (Test-Path $script:TestDir)) - { - $null = New-Item -path $script:TestDir -ItemType Directory - } - $script:TestAssemblyDir = [System.IO.Path]::GetTempPath() if(-not (Test-Path $script:TestAssemblyDir)) { @@ -448,14 +443,6 @@ namespace PowershellTestConfigNamespace $LocalStartupScriptPath = CreateStartupScript $LocalTestModulePath = CreateTestModule $LocalTestAssemblyName = CreateTestAssembly - $LocalTestDir = $script:TestDir - } - } - - AfterAll { - if ($IsNotSkipped) - { - Remove-Item $LocalTestDir -Recurse -Force -ErrorAction SilentlyContinue } } @@ -847,7 +834,7 @@ namespace PowershellTestConfigNamespace } It "Enable-PSSession Cmdlet creates a PSSession configuration with a name tied to PowerShell version." { - $endpointName = "PowerShell." + $PSVersionTable.GitCommitId + $endpointName = ("PowerShell." + $PSVersionTable.GitCommitId.ToString()).Replace("PowerShell.v","PowerShell.") $matchedEndpoint = Get-PSSessionConfiguration $endpointName -ErrorAction SilentlyContinue $matchedEndpoint | Should -Not -BeNullOrEmpty } @@ -855,6 +842,10 @@ namespace PowershellTestConfigNamespace It "Enable-PSSession Cmdlet creates a default PSSession configuration untied to a specific PowerShell version." { $dotPos = $PSVersionTable.PSVersion.ToString().IndexOf(".") $endpointName = "PowerShell." + $PSVersionTable.PSVersion.ToString().Substring(0, $dotPos) + if ($PSVersionTable.GitCommitId.Contains("preview")) + { + $endpointName += "-Preview" + } $matchedEndpoint = Get-PSSessionConfiguration $endpointName -ErrorAction SilentlyContinue $matchedEndpoint | Should -Not -BeNullOrEmpty } From d857b5635aa077f5620411f0f66e63b5bd86795a Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Thu, 28 Jun 2018 14:12:05 -0700 Subject: [PATCH 3/7] address Paul's feedback --- .../engine/remoting/commands/CustomShellCommands.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs index bba86b0acb1..8e3fe0bc391 100644 --- a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs +++ b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs @@ -1520,11 +1520,15 @@ internal static string GetWinrmPluginShellName() // TODO: This should be PSVersionInfo.PSVersionName once we get // closer to release. Right now it doesn't support alpha versions. string version = PSVersionInfo.GitCommitId; + + // We want the resulting endpoint name to be: PowerShell.6 + // However, the GitCommitId has a `v` like `v6.1.0`, so we need to remove + // the `v` if (version.StartsWith("v")) { version = version.Substring(1, version.Length - 1); } - + return System.String.Concat("PowerShell.", version); } @@ -4895,6 +4899,8 @@ function Enable-PSRemoting if ($dotPos -ne -1) {{ $powershellVersionMajor = $powershellVersionMajor.Substring(0, $dotPos) }} + # If we are running a Preview version, we don't want to clobber the generic PowerShell.6 endpoint + # but instead creating a PowerShell.6-Preview endpoint if ($PSVersionTable.PSVersion.ToString().Contains(""preview"")) {{ $powershellVersionMajor += ""-Preview"" From 38e5465b9bb1b7e9f3f63632d3624f9e4debdc6d Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Thu, 28 Jun 2018 14:31:02 -0700 Subject: [PATCH 4/7] address Dan's feedback --- .../engine/remoting/commands/CustomShellCommands.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs index 8e3fe0bc391..d1356da4dbb 100644 --- a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs +++ b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs @@ -1526,7 +1526,7 @@ internal static string GetWinrmPluginShellName() // the `v` if (version.StartsWith("v")) { - version = version.Substring(1, version.Length - 1); + version = version.Substring(1); } return System.String.Concat("PowerShell.", version); From aa6b5ce3419175b9d3c275f4908c944c142c2969 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Thu, 28 Jun 2018 16:56:23 -0700 Subject: [PATCH 5/7] [feature] fix JEA tests --- .../remoting/commands/CustomShellCommands.cs | 8 ++++- .../PSSessionConfiguration.Tests.ps1 | 35 +++++++++++-------- .../Remoting/RemoteSession.Basic.Tests.ps1 | 3 +- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs index d1356da4dbb..7b6335b2e99 100644 --- a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs +++ b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs @@ -1529,7 +1529,13 @@ internal static string GetWinrmPluginShellName() version = version.Substring(1); } - return System.String.Concat("PowerShell.", version); + string shellName = System.String.Concat("PowerShell.", version); + if (version.Contains("preview")) + { + shellName += "-Preview"; + } + + return shellName; } /// diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 index 102405d0f66..14b1b23c607 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 @@ -104,13 +104,13 @@ try # Create new Config File function CreateTestConfigFile { - $TestConfigFileLoc = join-path $TestDrive "Remoting" + $TestConfigFileLoc = Join-Path $TestDrive "Remoting" if(-not (Test-path $TestConfigFileLoc)) { $null = New-Item -Path $TestConfigFileLoc -ItemType Directory -Force -ErrorAction Stop } - $TestConfigFile = join-path $TestConfigFileLoc "TestConfigFile.pssc" + $TestConfigFile = Join-Path $TestConfigFileLoc "TestConfigFile.pssc" $null = New-PSSessionConfigurationFile -Path $TestConfigFile -SessionType Default return $TestConfigFile @@ -366,7 +366,7 @@ try `$script:testvariable = "testValue" "@ - $TestScript = join-path $script:TestDir "StartupTestScript.ps1" + $TestScript = Join-Path $script:TestDir "StartupTestScript.ps1" $null = Set-Content -path $TestScript -Value $ScriptContent return $TestScript @@ -375,7 +375,7 @@ try # Create new Config File function CreateTestConfigFile { - $TestConfigFile = join-path $script:TestDir "TestConfigFile.pssc" + $TestConfigFile = Join-Path $script:TestDir "TestConfigFile.pssc" $null = New-PSSessionConfigurationFile -Path $TestConfigFile -SessionType Default return $TestConfigFile } @@ -394,7 +394,7 @@ Export-ModuleMember IsTestModuleImported $null = New-Item -Path $TestModuleFileLoc -ItemType Directory -Force -ErrorAction Stop } - $TestModuleFile = join-path $TestModuleFileLoc "TestModule.psm1" + $TestModuleFile = Join-Path $TestModuleFileLoc "TestModule.psm1" $null = Set-Content -path $TestModuleFile -Value $ScriptContent return $TestModuleFile @@ -424,16 +424,21 @@ namespace PowershellTestConfigNamespace } } "@ - $script:SourceFile = join-path $script:TestAssemblyDir "PowershellTestConfig.cs" + $script:SourceFile = Join-Path $script:TestAssemblyDir "PowershellTestConfig.cs" $PscConfigDef | out-file $script:SourceFile -Encoding ascii -Force - $TestAssemblyName = "TestAssembly" + (New-Guid) + ".dll" - $TestAssemblyPath = join-path $script:TestAssemblyDir $TestAssemblyName + $TestAssemblyName = "TestAssembly.dll" + $TestAssemblyPath = Join-Path $script:TestAssemblyDir $TestAssemblyName Add-Type -path $script:SourceFile -OutputAssembly $TestAssemblyPath return $TestAssemblyName } - $script:TestDir = join-path $TestDrive "Remoting" - $script:TestAssemblyDir = [System.IO.Path]::GetTempPath() + $script:TestDir = Join-Path $TestDrive "Remoting" + if(-not (Test-Path $script:TestDir)) + { + $null = New-Item -path $script:TestDir -ItemType Directory + } + + $script:TestAssemblyDir = Join-Path $TestDrive "AssemblyDir" if(-not (Test-Path $script:TestAssemblyDir)) { $null = New-Item -path $script:TestAssemblyDir -ItemType Directory @@ -608,11 +613,11 @@ namespace PowershellTestConfigNamespace It "Validate New-PSSessionConfigurationFile can successfully create a valid PSSessionConfigurationFile" { - $configFilePath = join-path $TestDrive "SamplePSSessionConfigurationFile.pssc" + $configFilePath = Join-Path $TestDrive "SamplePSSessionConfigurationFile.pssc" try { New-PSSessionConfigurationFile $configFilePath - $result = get-content $configFilePath | Out-String + $result = Get-Content $configFilePath | Out-String } finally { @@ -740,7 +745,7 @@ namespace PowershellTestConfigNamespace It "Validate FullyQualifiedErrorId from Test-PSSessionConfigurationFile when an invalid pssc file is provided as input and -Verbose parameter is specified" { - $configFilePath = join-path $TestDrive "SamplePSSessionConfigurationFile.pssc" + $configFilePath = Join-Path $TestDrive "SamplePSSessionConfigurationFile.pssc" "InvalidData" | Out-File $configFilePath Test-PSSessionConfigurationFile $configFilePath -Verbose -ErrorAction Stop | Should -BeFalse @@ -749,7 +754,7 @@ namespace PowershellTestConfigNamespace It "Test case verifies that the generated config file passes validation" { # Path the config file - $configFilePath = join-path $TestDrive "SamplePSSessionConfigurationFile.pssc" + $configFilePath = Join-Path $TestDrive "SamplePSSessionConfigurationFile.pssc" $updatedFunctionDefn = @() foreach($currentDefination in $parmMap.FunctionDefinitions) @@ -834,7 +839,7 @@ namespace PowershellTestConfigNamespace } It "Enable-PSSession Cmdlet creates a PSSession configuration with a name tied to PowerShell version." { - $endpointName = ("PowerShell." + $PSVersionTable.GitCommitId.ToString()).Replace("PowerShell.v","PowerShell.") + $endpointName = "PowerShell." + $PSVersionTable.GitCommitId.ToString().Substring(1) # Remove the v from the beginning $matchedEndpoint = Get-PSSessionConfiguration $endpointName -ErrorAction SilentlyContinue $matchedEndpoint | Should -Not -BeNullOrEmpty } diff --git a/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 b/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 index 62c22baefd8..d47ee33e667 100644 --- a/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 +++ b/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 @@ -129,7 +129,8 @@ Describe "Remoting loopback tests" -Tags @('CI', 'RequireAdminOnWindows') { else { Enable-PSRemoting -SkipNetworkProfileCheck - $endPoint = (Get-PSSessionConfiguration -Name "PowerShell.$(${PSVersionTable}.GitCommitId)").Name + $psversion = $PSVersionTable.GitCommitId.ToString().Substring(1) # Remove the v from the beginning + $endPoint = (Get-PSSessionConfiguration -Name "PowerShell.$psversion").Name $disconnectedSession = New-RemoteSession -ConfigurationName $endPoint -ComputerName localhost | Disconnect-PSSession $closedSession = New-RemoteSession -ConfigurationName $endPoint -ComputerName localhost $closedSession.Runspace.Close() From 36954a5e2f22e065f20bc98a62e8069c27f08d38 Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Mon, 16 Jul 2018 13:49:40 -0700 Subject: [PATCH 6/7] [feature] based on PS-Committee discussion, decision is to remove `v` from GitCommitId --- .../engine/PSVersionInfo.cs | 4 ++-- .../remoting/commands/CustomShellCommands.cs | 24 ++----------------- test/powershell/Host/ConsoleHost.Tests.ps1 | 2 +- test/powershell/Host/PSVersionTable.Tests.ps1 | 8 +++---- .../PSSessionConfiguration.Tests.ps1 | 6 ++--- .../Remoting/RemoteSession.Basic.Tests.ps1 | 3 +-- 6 files changed, 13 insertions(+), 34 deletions(-) diff --git a/src/System.Management.Automation/engine/PSVersionInfo.cs b/src/System.Management.Automation/engine/PSVersionInfo.cs index 335cd678c05..e6d167f669d 100644 --- a/src/System.Management.Automation/engine/PSVersionInfo.cs +++ b/src/System.Management.Automation/engine/PSVersionInfo.cs @@ -78,11 +78,11 @@ static PSVersionInfo() if (productVersion.Contains(" Commits: ")) { - rawGitCommitId = "v" + productVersion.Replace(" Commits: ", "-").Replace(" SHA: ", "-g"); + rawGitCommitId = productVersion.Replace(" Commits: ", "-").Replace(" SHA: ", "-g"); } else { - rawGitCommitId = "v" + mainVersion; + rawGitCommitId = mainVersion; } s_psV6Version = new SemanticVersion(mainVersion); diff --git a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs index 7b6335b2e99..d495bfa4c4f 100644 --- a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs +++ b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs @@ -1517,25 +1517,7 @@ internal static string GetRunAsVirtualAccountGroupsString(string[] groups) internal static string GetWinrmPluginShellName() { // PowerShell Core uses a versioned directory to hold the plugin - // TODO: This should be PSVersionInfo.PSVersionName once we get - // closer to release. Right now it doesn't support alpha versions. - string version = PSVersionInfo.GitCommitId; - - // We want the resulting endpoint name to be: PowerShell.6 - // However, the GitCommitId has a `v` like `v6.1.0`, so we need to remove - // the `v` - if (version.StartsWith("v")) - { - version = version.Substring(1); - } - - string shellName = System.String.Concat("PowerShell.", version); - if (version.Contains("preview")) - { - shellName += "-Preview"; - } - - return shellName; + return System.String.Concat("PowerShell.", PSVersionInfo.GitCommitId); } /// @@ -1545,8 +1527,6 @@ internal static string GetWinrmPluginShellName() internal static string GetWinrmPluginDllPath() { // PowerShell Core uses its versioned directory instead of system32 - // TODO: This should be PSVersionInfo.PSVersionName once we get - // closer to release. Right now it doesn't support alpha versions. string pluginDllDirectory = System.IO.Path.Combine("%windir%\\system32\\PowerShell", PSVersionInfo.GitCommitId); return System.IO.Path.Combine(pluginDllDirectory, RemotingConstants.PSPluginDLLName); } @@ -4909,7 +4889,7 @@ function Enable-PSRemoting # but instead creating a PowerShell.6-Preview endpoint if ($PSVersionTable.PSVersion.ToString().Contains(""preview"")) {{ - $powershellVersionMajor += ""-Preview"" + $powershellVersionMajor += ""-preview"" }} Register-EndpointIfNotPresent -Name (""PowerShell."" + $powershellVersionMajor) $Force $queryForRegisterDefault $captionForRegisterDefault diff --git a/test/powershell/Host/ConsoleHost.Tests.ps1 b/test/powershell/Host/ConsoleHost.Tests.ps1 index 91400a5b122..d4672483476 100644 --- a/test/powershell/Host/ConsoleHost.Tests.ps1 +++ b/test/powershell/Host/ConsoleHost.Tests.ps1 @@ -674,7 +674,7 @@ Describe "Pwsh exe resources tests" -Tag CI { It "Resource strings are embedded in the executable" -Skip:(!$IsWindows) { $pwsh = Get-Item -Path "$PSHOME\pwsh.exe" $pwsh.VersionInfo.FileVersion | Should -BeExactly $PSVersionTable.PSVersion.ToString().Split("-")[0] - "v" + $pwsh.VersionInfo.ProductVersion.Replace("-dirty","") | Should -BeExactly $PSVersionTable.GitCommitId + $pwsh.VersionInfo.ProductVersion.Replace("-dirty","") | Should -BeExactly $PSVersionTable.GitCommitId $pwsh.VersionInfo.ProductName | Should -BeExactly "PowerShell Core 6" } diff --git a/test/powershell/Host/PSVersionTable.Tests.ps1 b/test/powershell/Host/PSVersionTable.Tests.ps1 index c3fc1ab2f6c..c1e0d5ef837 100644 --- a/test/powershell/Host/PSVersionTable.Tests.ps1 +++ b/test/powershell/Host/PSVersionTable.Tests.ps1 @@ -7,19 +7,19 @@ Describe "PSVersionTable" -Tags "CI" { $formattedVersion = $sma.VersionInfo.ProductVersion $mainVersionPattern = "(\d+\.\d+\.\d+)(-.+)?" - $fullVersionPattern = "^v(\d+\.\d+\.\d+)(-.+)?-(\d+)-g(.+)$" + $fullVersionPattern = "^(\d+\.\d+\.\d+)(-.+)?-(\d+)-g(.+)$" $expectedPSVersion = ($formattedVersion -split " ")[0] $expectedVersionPattern = "^$mainVersionPattern$" if ($formattedVersion.Contains(" Commits: ")) { - $rawGitCommitId = "v" + $formattedVersion.Replace(" Commits: ", "-").Replace(" SHA: ", "-g") + $rawGitCommitId = $formattedVersion.Replace(" Commits: ", "-").Replace(" SHA: ", "-g") $expectedGitCommitIdPattern = $fullVersionPattern $unexpectectGitCommitIdPattern = "qwerty" } else { - $rawGitCommitId = "v" + ($formattedVersion -split " SHA: ")[0] - $expectedGitCommitIdPattern = "^v$mainVersionPattern$" + $rawGitCommitId = ($formattedVersion -split " SHA: ")[0] + $expectedGitCommitIdPattern = "^$mainVersionPattern$" $unexpectectGitCommitIdPattern = $fullVersionPattern } } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 index 14b1b23c607..31669f45525 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Core/PSSessionConfiguration.Tests.ps1 @@ -17,7 +17,7 @@ try # if ($IsNotSkipped) { - $endpointName = "PowerShell.$($psversiontable.GitCommitId)".Replace("PowerShell.v","PowerShell.") + $endpointName = "PowerShell.$($psversiontable.GitCommitId)" $matchedEndpoint = Get-PSSessionConfiguration $endpointName -ErrorAction SilentlyContinue @@ -839,7 +839,7 @@ namespace PowershellTestConfigNamespace } It "Enable-PSSession Cmdlet creates a PSSession configuration with a name tied to PowerShell version." { - $endpointName = "PowerShell." + $PSVersionTable.GitCommitId.ToString().Substring(1) # Remove the v from the beginning + $endpointName = "PowerShell." + $PSVersionTable.GitCommitId.ToString() $matchedEndpoint = Get-PSSessionConfiguration $endpointName -ErrorAction SilentlyContinue $matchedEndpoint | Should -Not -BeNullOrEmpty } @@ -849,7 +849,7 @@ namespace PowershellTestConfigNamespace $endpointName = "PowerShell." + $PSVersionTable.PSVersion.ToString().Substring(0, $dotPos) if ($PSVersionTable.GitCommitId.Contains("preview")) { - $endpointName += "-Preview" + $endpointName += "-preview" } $matchedEndpoint = Get-PSSessionConfiguration $endpointName -ErrorAction SilentlyContinue $matchedEndpoint | Should -Not -BeNullOrEmpty diff --git a/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 b/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 index d47ee33e667..62c22baefd8 100644 --- a/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 +++ b/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 @@ -129,8 +129,7 @@ Describe "Remoting loopback tests" -Tags @('CI', 'RequireAdminOnWindows') { else { Enable-PSRemoting -SkipNetworkProfileCheck - $psversion = $PSVersionTable.GitCommitId.ToString().Substring(1) # Remove the v from the beginning - $endPoint = (Get-PSSessionConfiguration -Name "PowerShell.$psversion").Name + $endPoint = (Get-PSSessionConfiguration -Name "PowerShell.$(${PSVersionTable}.GitCommitId)").Name $disconnectedSession = New-RemoteSession -ConfigurationName $endPoint -ComputerName localhost | Disconnect-PSSession $closedSession = New-RemoteSession -ConfigurationName $endPoint -ComputerName localhost $closedSession.Runspace.Close() From 308e51d25fdbc2811f5c2957064b3206a478882a Mon Sep 17 00:00:00 2001 From: "Steve Lee (POWERSHELL)" Date: Mon, 16 Jul 2018 17:36:32 -0700 Subject: [PATCH 7/7] [feature] address Dongbo's feedback --- .../engine/remoting/commands/CustomShellCommands.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs index d495bfa4c4f..c6570206c14 100644 --- a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs +++ b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs @@ -4886,8 +4886,8 @@ function Enable-PSRemoting $powershellVersionMajor = $powershellVersionMajor.Substring(0, $dotPos) }} # If we are running a Preview version, we don't want to clobber the generic PowerShell.6 endpoint - # but instead creating a PowerShell.6-Preview endpoint - if ($PSVersionTable.PSVersion.ToString().Contains(""preview"")) + # but instead create a PowerShell.6-Preview endpoint + if ($PSVersionTable.PSVersion.PreReleaseLabel) {{ $powershellVersionMajor += ""-preview"" }}