If we need to check what Windows version a PowerShell script run on, we usually use a statement like this:
So imagine our surprise when we saw what happens when you run this as a script in PrimalScript:
Instead of reporting the actual Windows version, it appears as if we are running in Windows 8 instead of 8.1
To make sure we didn’t have a glitch in PrimalScript (and because we didn’t quite trust our eyes), we packaged the script as an executable and ran that.
Same result, it reports the incorrect version number.
According to Microsoft this is intentional:
http://msdn.microsoft.com/en-us/library/windows/desktop/dn302074(v=vs.85).aspx
Before you ask, we have no idea what could possibly possess Microsoft to break such a fundamental API call so that it reports an incorrect version.
As shown on the web page we linked to above, you have to tag your executable in a manifest as supporting Windows 8.1 in order to get a correct version number.
In the packager settings you have to switch to a custom manifest and and specify the manifest file.
If you follow this patch and re-package the executable it will now report the correct version number.
Needless to say, we will update our default manifest and the packager to accommodate this latest “it’s not a bug, it’s a feature” play by Microsoft in the next service build.
I found this issue as well, but only on instances of Windows 8 that were then “upgraded” to 8.1 with the package available from the Store. On natively installed 8.1, [System.Environment]::OSVersion.Version correctly returns the 9600 build. Likewise, WS 2012 and 2012R2 are 9200 and 9600 respectively. On my 8.1 (upgrade) machine, querying the registry or Win32_OperatingSystem class correctly returns 9600 as does $PSVersionTable.
Powershell.exe is obviously tagged as an application supporting 8.1. Unless you operate at the SDK level or with executables that are not part of the OS you will not see the bug. Well, what MS calls a feature….
I see. However, the built in ISE does show the bug.
Seriously? How could I miss that? I’ll check that. But not too surprising. Left hand doesn’t know what the right hand does.
DMCA Force liked this on Facebook.