Fix [System.Environment]::OSVersion for PowerShell Studio on Windows 10

Post feature requests, product enhancement ideas, and other product-specific suggestions here. Do not post bug reports.
Forum rules
Do not post any licensing information in this forum.
Locked
User avatar
remkow
Posts: 7
Joined: Fri Jul 10, 2015 3:53 am

Fix [System.Environment]::OSVersion for PowerShell Studio on Windows 10

Post by remkow »

When I run the following code from PowerShell Studio 2017

[System.Environment]::OSVersion
This is the output:

>> Platform: V5 64Bit (STA)

Platform ServicePack Version VersionString
-------- ----------- ------- -------------
Win32NT 6.3.9600.0 Microsoft Windows NT 6.3.9600.0
Both PowerShell.exe and PowerShell ISE on Windows 10 output the correct version information:

[System.Environment]::OSVersion

Platform ServicePack Version VersionString
-------- ----------- ------- -------------
Win32NT 10.0.15063.0 Microsoft Windows NT 10.0.15063.0
Can this be fixed? Perhaps relevant: https://www.remkoweijnen.nl/blog/2017/0 ... owershell/

DevinL
Site Admin
Posts: 1098
Joined: Mon Aug 17, 2015 2:25 pm

Re: Fix [System.Environment]::OSVersion for PowerShell Studio on Windows 10

Post by DevinL »

Which version of PowerShell Studio would you happen to be running?

This was brought to our attention previously and has since been fixed: viewtopic.php?f=12&t=11300
DevinL
SAPIEN Technologies, Inc.

User avatar
remkow
Posts: 7
Joined: Fri Jul 10, 2015 3:53 am

Re: Fix [System.Environment]::OSVersion for PowerShell Studio on Windows 10

Post by remkow »

2017 build 5.4.136, let me check after updating

User avatar
Alexander Riedel
Posts: 7501
Joined: Tue May 29, 2007 4:43 pm

Re: Fix [System.Environment]::OSVersion for PowerShell Studio on Windows 10

Post by Alexander Riedel »

The API you use to determine the Windows version is deprecated: https://msdn.microsoft.com/en-us/librar ... .110).aspx

"Starting with Windows 8, the OSVersion property returns the same major and minor version numbers for all Windows platforms. Therefore, we do not recommend that you retrieve the value of this property to determine the operating system version."

Here are a few other ways of doing this:
http://stackoverflow.com/questions/7330 ... ne/7330368
Or use the method in the blog article you provided.

While we tagged the executable in question now as a Windows 10 executable, it is not a reliable way to determine the OS version.
The API you use will ALWAYS only report the largest version a product is tagged for, not the true OS version.
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
remkow
Posts: 7
Joined: Fri Jul 10, 2015 3:53 am

Re: Fix [System.Environment]::OSVersion for PowerShell Studio on Windows 10

Post by remkow »

Fixed indeed:
Platform ServicePack Version VersionString
-------- ----------- ------- -------------
Win32NT 10.0.15063.0 Microsoft Windows NT 10.0.15063.0

Locked