How To Get The PowerShell Edition
[PowerShell]
Yesterday’s post, “How To Get The PowerShell Version”, discussed how to get the PowerShell version that you are running under.
In this post, we will look at a simpler challenge - how to get the edition.
As a reminder, there are two editions of PowerShell:
- PowerShell For Windows (version
5and below) - PowerShell Core (Version
6and above,7being the current)
One way would be to ride on what we learned yesterday.
We can use this invocation:
$PSVersionTable.PSVersion
From this, we can extract the property MajorVersion.
If it is 5, then that is PowerShell for Windows.
If it is larger than 5, then that is cross-platform PowerShell Core.
There is another, simpler way to obtain this information..
We can use the following invocation:
$PSVersionTable.PSEdition
If we run it under PowerShell for Windows, we get the following result:

It returns a string value, Desktop
We can also run it under PowerShell Core on Windows.

It returns a string value, Core
On macOS, which can run PowerShell Core, it returns the same:

TLDR
You can obtain the PowerShell edition from the $PSVersionTable.PSEdition invocation.
Happy hacking!