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"

@Borgquite
Copy link
Copy Markdown
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
Copy link
Copy Markdown
Contributor

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

@alerickson, @anamnavi

Copy link
Copy Markdown
Member

@andyleejordan andyleejordan left a comment

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.

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

Labels

None yet

Projects

None yet

3 participants