Skip to content

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

Merged
anamnavi merged 1 commit into
PowerShell:masterfrom
Borgquite:fixcoredetect
May 15, 2026
Merged

Fix detection of Windows PS vs PS Core resolving module directory issues#1974
anamnavi merged 1 commit into
PowerShell:masterfrom
Borgquite:fixcoredetect

Conversation

@Borgquite

@Borgquite Borgquite commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

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
Contributor Author

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

@Borgquite

Copy link
Copy Markdown
Contributor Author

Is anyone able to review this simple change that should resolve a number of people's issues with the module?

@o-l-a-v

o-l-a-v commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

@alerickson, @anamnavi

@andyleejordan andyleejordan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core problem is identified correctly. The Host value is not deterministic and shouldn't be relied on for this, but yes PSEdition should.

@Borgquite

Copy link
Copy Markdown
Contributor Author

Any chance of a review & merge here please?

@anamnavi anamnavi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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

Labels

None yet

Projects

None yet

4 participants