Skip to content

Commit 0706243

Browse files
committed
Fixing the logic to determine if the current PowerShell session is Windows PowerShell or PowerShell Core.
1 parent 9c8bd26 commit 0706243

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

src/code/Utils.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,15 +1161,14 @@ private static string GetHomeOrCreateTempHome()
11611161
return s_tempHome;
11621162
}
11631163

1164-
private readonly static Version PSVersion6 = new Version(6, 0);
11651164
private static void GetStandardPlatformPaths(
11661165
PSCmdlet psCmdlet,
11671166
out string localUserDir,
11681167
out string allUsersDir)
11691168
{
11701169
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
11711170
{
1172-
string powerShellType = (psCmdlet.Host.Version >= PSVersion6) ? "PowerShell" : "WindowsPowerShell";
1171+
string powerShellType = ((psCmdlet.GetVariableValue("PSEdition") as string) == "Core") ? "PowerShell" : "WindowsPowerShell";
11731172
localUserDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), powerShellType);
11741173
allUsersDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), powerShellType);
11751174
}
@@ -1189,7 +1188,7 @@ private static void GetStandardPlatformPaths(
11891188

11901189
public static bool GetIsWindowsPowerShell(PSCmdlet psCmdlet)
11911190
{
1192-
return psCmdlet.Host.Version < PSVersion6;
1191+
return ((psCmdlet.GetVariableValue("PSEdition") as string) != "Core");
11931192
}
11941193

11951194
/// <summary>

0 commit comments

Comments
 (0)