Skip to content

Fix detection of Windows PS vs PS Core resolving module directory issues#1974

Open
Borgquite wants to merge 1 commit intoPowerShell:masterfrom
Borgquite:fixcoredetect
Open

Fix detection of Windows PS vs PS Core resolving module directory issues#1974
Borgquite wants to merge 1 commit intoPowerShell:masterfrom
Borgquite:fixcoredetect

Conversation

@Borgquite
Copy link
Copy Markdown

@Borgquite Borgquite commented Apr 10, 2026

PR Summary

Fix detection of Windows PS vs PS Core resolving module directory issues

PR Context

Switch to using PSEdition instead of Host.Version as running PowerShell under certain instances does not return correct version (e.g. VSCode, .NET Interactive, Ruby/Puppet)

The PSEdition variable returns $null, or 'Desktop' under Windows PowerShell, and 'Core' under PowerShell Core. The code therefore checks for 'Core' to determine if Core is in use - otherwise, it determines Windows PowerShell.

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_editions?view=powershell-7.5

This is the method preferred by the PowerShell team for identifying the use of PowerShell Core, rather than using version numbers

https://devblogs.microsoft.com/scripting/powertip-identify-if-you-are-running-on-powershell-core/

PR Checklist

@Borgquite
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="Mission Aviation Fellowship International"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant