Repository navigation
Closed
MicrosoftDocs/PowerShell-Docs
#2227Labels
Area-Maintainers-Documentationspecific to documentation in this repoResolution-AnsweredThe question is answered.
Description
$PSVersionTable is returning an incorrect platform for macOS High Sierra 10.13.3.
Source: Engine Update Release Notes for PowerShell Core 6.0.
Steps to reproduce
> $PSVersionTable.PlatformExpected behavior
MacOSX
Actual behavior
Unix
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 6.0.2
PSEdition Core
GitCommitId v6.0.2
OS Darwin 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
> $IsMacOS
True $ system_profiler SPSoftwareDataType | grep "System Version"
System Version: macOS 10.13.3 (17D102)Metadata
Metadata
Assignees
Labels
Area-Maintainers-Documentationspecific to documentation in this repoResolution-AnsweredThe question is answered.
Activity
mklement0 commentedon Mar 27, 2018
Unfortunately, the release notes are incorrect.
What is correct is that PowerShell takes the information from
[System.Environment]::OSVersion.Platform, i.e., from CoreFX and there,perhaps confusingly, the behavior is by design (from dotnet/platform-compat#29, emphasis added):
More backstory at https://github.com/dotnet/corefx/issues/19694
The unfortunate thing is that the
[System.PlatformID]enum that[System.Environment]::OSVersion.Platformreturn values are instances of still containsMacOSXas a value, but only for historical reasons.The upshot is:
[System.Environment]::OSVersion.Platformis only useful to contrast platforms with Unix heritage in the abstract with Windows - i.e., to distinguish Linux and macOS on the one hand from Windows on the other.$IsUnixvariable to reflect this distinction.$IsMacOsis therefore the best way to determine if you're running on macOS.$PSVersionTable.OS- which contains the value of[System.Runtime.InteropServices.RuntimeInformation]::OSDescription- also reflects the specific platform, but only in a semi-structured way that furthermore refers to macOS as Darwin, the open-source OS on which macOS is based.$PSVersionTable.Platform returns Unix on macOS
SteveL-MSFT commentedon Mar 27, 2018
Thanks for noticing this. I submitted a fix: MicrosoftDocs/PowerShell-Docs#2227
Note that you can always click the
Editlink on the doc page which will take you to GitHub and submit a fix yourself. Thanks!mklement0 commentedon Mar 27, 2018
Steve Lee (@SteveL-MSFT):
Thanks - hadn't even realized that it was a living document.
I think it's also important to document the behavior in
about_Automatic_Variables, so I've created MicrosoftDocs/PowerShell-Docs#2229$PSVersionTable.Platform returns Unix on macOS (#2227)
Merging latest updates in to live (#2239)
Merging latest updates into live (#2250)