Skip to content

Commit 2c7709b

Browse files
authored
Merge pull request #347 from PowerShell/daviwil/fix-346
Fix #346: GetVersionDetails failing due to empty environment variable
2 parents 003fc2b + bdfc86b commit 2c7709b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/PowerShellEditorServices/Session/PowerShellVersionDetails.cs

+9-6
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,16 @@ public static PowerShellVersionDetails GetVersionDetails(Runspace runspace)
134134
}
135135

136136
var arch = PowerShellContext.ExecuteScriptAndGetItem<string>("$env:PROCESSOR_ARCHITECTURE", runspace);
137-
if (string.Equals(arch, "AMD64", StringComparison.CurrentCultureIgnoreCase))
137+
if (arch != null)
138138
{
139-
architecture = PowerShellProcessArchitecture.X64;
140-
}
141-
else if (string.Equals(arch, "x86", StringComparison.CurrentCultureIgnoreCase))
142-
{
143-
architecture = PowerShellProcessArchitecture.X86;
139+
if (string.Equals(arch, "AMD64", StringComparison.CurrentCultureIgnoreCase))
140+
{
141+
architecture = PowerShellProcessArchitecture.X64;
142+
}
143+
else if (string.Equals(arch, "x86", StringComparison.CurrentCultureIgnoreCase))
144+
{
145+
architecture = PowerShellProcessArchitecture.X86;
146+
}
144147
}
145148
}
146149
}

0 commit comments

Comments
 (0)