You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Powershell Core Reports the wrong version of windows when referencing c# Assemblies #6452
I apologize if this issue already exists and I missed it or if you are already aware of this issue. This is my first time submitting an issue here.
When using the System.Environment assembly to get the Windows OS version that is it running PowerShell reports the same version of Windows as Windows 8/Windows Server 2012 instead of the correct version of Windows on Windows 8.1/Windows Server 2012R2 and Windows 10/Windows Server 2016. I found a stackoverflow article referencing Windows Developer document. It is probably not this simple but you might need to modify your manifest file for your PowerShell builds.
Steps to reproduce
[System.Environment]::OSVersion.Version
Expected behavior
[System.Environment]::OSVersion.Version
Major Minor Build Revision
----- ----- ----- --------
10 0 16299 0
Actual behavior
[System.Environment]::OSVersion.Version
Major Minor Build Revision
----- ----- ----- --------
6 2 9200 0
Environment data
>$PSVersionTable
Name Value
---------
PSVersion 6.0.2
PSEdition Core
GitCommitId v6.0.2
OS Microsoft Windows 10.0.16299
Platform Win32NT
PSCompatibleVersions {1.0,2.0,3.0,4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
I don't think the results relates to the actual Windows OS Build. It's something else:
PS [81] > [System.Environment]::OSVersion.VersionString
Microsoft Windows NT 6.2.9200.0
PS [70] > cmd
C:\Program Files\PowerShell\6.0.2>ver
Microsoft Windows [Version 10.0.17127.1]
PS [84] > $PSVersionTable.os
Microsoft Windows 10.0.17127
I'm sure it's the internal Windows Build version.
:)
* For applications that have been manifested for Windows 8.1 or Windows 10. Applications not manifested for Windows 8.1 or Windows 10 will return the Windows 8 OS version value (6.2). To manifest your applications for Windows 8.1 or Windows 10, refer to Targeting your application for Windows.
Activity
MaximoTrinidad commentedon Mar 21, 2018
arahja,
I don't think the results relates to the actual Windows OS Build. It's something else:
I'm sure it's the internal Windows Build version.
:)
MaximoTrinidad commentedon Mar 21, 2018
Ah! I forgot to include the following link which shows the Windows OS Version numbers:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx
OK! So, this confirms that the versions are incorrect!
Good one arahja!
But, this is not PowerShell, it's in .NET Environment Class:
https://msdn.microsoft.com/en-us/library/system.environment.osversion(v=vs.100).aspx
:)
arahja commentedon Mar 21, 2018
You might find the following text in Windows Developer document interesting:
* For applications that have been manifested for Windows 8.1 or Windows 10. Applications not manifested for Windows 8.1 or Windows 10 will return the Windows 8 OS version value (6.2). To manifest your applications for Windows 8.1 or Windows 10, refer to Targeting your application for Windows.