@@ -11,34 +11,11 @@ namespace Microsoft.PowerShell.EditorServices.Services.PowerShell.Context
1111{
1212 using System . Management . Automation ;
1313
14- /// <summary>
15- /// Defines the possible enumeration values for the PowerShell process architecture.
16- /// </summary>
17- internal enum PowerShellProcessArchitecture
18- {
19- /// <summary>
20- /// The processor architecture is unknown or wasn't accessible.
21- /// </summary>
22- Unknown ,
23-
24- /// <summary>
25- /// The processor architecture is 32-bit.
26- /// </summary>
27- X86 ,
28-
29- /// <summary>
30- /// The processor architecture is 64-bit.
31- /// </summary>
32- X64
33- }
34-
3514 /// <summary>
3615 /// Provides details about the version of the PowerShell runtime.
3716 /// </summary>
3817 internal class PowerShellVersionDetails
3918 {
40- #region Properties
41-
4219 /// <summary>
4320 /// Gets the version of the PowerShell runtime.
4421 /// </summary>
@@ -55,40 +32,26 @@ internal class PowerShellVersionDetails
5532 /// </summary>
5633 public string Edition { get ; }
5734
58- /// <summary>
59- /// Gets the architecture of the PowerShell process.
60- /// </summary>
61- public PowerShellProcessArchitecture Architecture { get ; }
62-
63- #endregion
64-
65- #region Constructors
66-
6735 /// <summary>
6836 /// Creates an instance of the PowerShellVersionDetails class.
6937 /// </summary>
7038 /// <param name="version">The version of the PowerShell runtime.</param>
7139 /// <param name="versionString">A string representation of the PowerShell version.</param>
7240 /// <param name="editionString">The string representation of the PowerShell edition.</param>
73- /// <param name="architecture">The processor architecture.</param>
7441 public PowerShellVersionDetails (
7542 Version version ,
7643 string versionString ,
77- string editionString ,
78- PowerShellProcessArchitecture architecture )
44+ string editionString )
7945 {
8046 Version = version ;
8147 VersionString = versionString ;
8248 Edition = editionString ;
83- Architecture = architecture ;
8449 }
8550
86- #endregion
87-
88- #region Public Methods
89-
9051 /// <summary>
91- /// Gets the PowerShell version details for the given runspace.
52+ /// Gets the PowerShell version details for the given runspace. This doesn't use
53+ /// VersionUtils because we may be remoting, and therefore want the remote runspace's
54+ /// version, not the local process.
9255 /// </summary>
9356 /// <param name="logger">An ILogger implementation used for writing log messages.</param>
9457 /// <param name="pwsh">The PowerShell instance for which to get the version.</param>
@@ -98,7 +61,6 @@ public static PowerShellVersionDetails GetVersionDetails(ILogger logger, PowerSh
9861 Version powerShellVersion = new ( 5 , 0 ) ;
9962 string versionString = null ;
10063 string powerShellEdition = "Desktop" ;
101- PowerShellProcessArchitecture architecture = PowerShellProcessArchitecture . Unknown ;
10264
10365 try
10466 {
@@ -129,25 +91,6 @@ public static PowerShellVersionDetails GetVersionDetails(ILogger logger, PowerSh
12991 }
13092
13193 versionString = psVersionTable [ "GitCommitId" ] is string gitCommitId ? gitCommitId : powerShellVersion . ToString ( ) ;
132-
133- PSCommand procArchCommand = new PSCommand ( ) . AddScript ( "$env:PROCESSOR_ARCHITECTURE" , useLocalScope : true ) ;
134-
135- string arch = pwsh
136- . AddScript ( "$env:PROCESSOR_ARCHITECTURE" , useLocalScope : true )
137- . InvokeAndClear < string > ( )
138- . FirstOrDefault ( ) ;
139-
140- if ( arch != null )
141- {
142- if ( string . Equals ( arch , "AMD64" , StringComparison . CurrentCultureIgnoreCase ) )
143- {
144- architecture = PowerShellProcessArchitecture . X64 ;
145- }
146- else if ( string . Equals ( arch , "x86" , StringComparison . CurrentCultureIgnoreCase ) )
147- {
148- architecture = PowerShellProcessArchitecture . X86 ;
149- }
150- }
15194 }
15295 }
15396 catch ( Exception ex )
@@ -156,13 +99,7 @@ public static PowerShellVersionDetails GetVersionDetails(ILogger logger, PowerSh
15699 "Failed to look up PowerShell version, defaulting to version 5.\r \n \r \n " + ex . ToString ( ) ) ;
157100 }
158101
159- return new PowerShellVersionDetails (
160- powerShellVersion ,
161- versionString ,
162- powerShellEdition ,
163- architecture ) ;
102+ return new PowerShellVersionDetails ( powerShellVersion , versionString , powerShellEdition ) ;
164103 }
165-
166- #endregion
167104 }
168105}
0 commit comments