Environment.OSVersion in PowerShell vs PowerShell ISE

4

Why is it that I see 2 different versions of my OS from PowerShell and PowerShell ISE?

The OS: Microsoft Windows Server 2012 R2 Datacenter Evaluation

PowerShell: version 4.0

PowerShell

PS C:\> [System.Environment]::OSVersion.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
6      3      9600   0

PowerShell ISE

PS C:\> [System.Environment]::OSVersion.Version

Major  Minor  Build  Revision
-----  -----  -----  --------
6      2      9200   0       

slybloty

Posted 2013-12-20T18:05:07.880

Reputation: 479

Answers

1

In Windows 8.1 / Server 2012 the GetVersionEx return the data for Windows 8 (6.2 Build 9200) if the application doesn't contain the supportedOS Id for Windows 8.1.

Looks like the GUI doesn't include this entry.

magicandre1981

Posted 2013-12-20T18:05:07.880

Reputation: 86 560

Windows Server 2012 is 6.2 version too. Build ? – Kiquenet – 2015-01-08T10:07:37.420

@Kiquenet yes, 2012 = 6.2 and 2012R2 = 6.3 – magicandre1981 – 2015-01-08T17:13:18.197

How difference Windows Server 2012 and Windows 8 and How difference Windows Server 2012 R2 and Windows 8.1 ? – Kiquenet – 2015-01-08T21:03:31.150

@Kiquenet which programming language do you use? – magicandre1981 – 2015-01-09T05:33:25.063

C# .NET and Powershell – Kiquenet – 2015-01-09T07:01:57.373

@Kiquenet make sure that the supportedOS Id entry is added to the app.config and the calls should be fine. Now use http://www.pinvoke.net/default.aspx/kernel32.getversionex and look for the wProductType value. Win8 = VER_NT_WORKSTATION

– magicandre1981 – 2015-01-09T18:16:16.177