Since PowerShell 6.1 for Windows / Linux / OSX has $PSVersionTable to GA, you can use the new $PSVersionTable , OS , Platform and GitCommitId
Update There are some breaking changes in v6.0.0-beta.3:
- Change the positional parameter for powershell.exe from -Command to -File
$PSVersionTable on:
Win32NT Platform Microsoft Windows 10.0.15063
PS C:\Users\LotPings> $PSVersionTable Name Value ---- ----- PSVersion 6.1.0 PSEdition Core GitCommitId 6.1.0 OS Microsoft Windows 10.0.17134 Platform Win32NT PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0
Linux (ubuntu) Unix Platform Linux (ubuntu)
PS /home/LotPings> $PSVersionTable Name Value ---- ----- PSVersion 6.1.0 PSEdition Core GitCommitId 6.1.0 OS Linux 4.15.0-34-generic
Darwin Unix Platform
PS /Users/LotPings> $PSVersionTable Name Value ---- ----- PSVersion 6.1.0 PSEdition Core GitCommitId 6.1.0 OS Darwin 17.7.0 Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RE... Platform Unix PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0
source share