Hi Olaf,
No, I have run this test several times but I may not have explained it correctly when I said version 10, that is just the major version, I omitted the minor/build/revision.
I have a vauge memory of reading an article explaining how the Win32_OperatingSystem version returns the underlying NT version and not the actual OS but I have not been able to find the article again.
Server 1 - 2016
PS C:\Users\Administrator> (get-ciminstance Win32_OperatingSystem).version
10.0.14393
PS C:\Users\Administrator> (get-ciminstance Win32_OperatingSystem).caption
Microsoft Windows Server 2016 Standard
PS C:\Users\Administrator> [system.environment]::osversion.Version
Major Minor Build Revision
10 0 14393 0
Server 2 - 2019
PS C:\Users\Administrator> (get-ciminstance Win32_OperatingSystem).version
10.0.17763
PS C:\Users\Administrator> (get-ciminstance Win32_OperatingSystem).caption
Microsoft Windows Server 2019 Standard
PS C:\Users\Administrator> [system.environment]::osversion.Version
Major Minor Build Revision
10 0 17763 0
For reference, from my notes previous version of windows are:
2012r2 - 6.3
2012r1 - 6.2
2008r2 - 6.1
2008r1 - 6.0
Due to the previous changes in Major/Minor version with each release that is all our code is structed to handle, as such when we hit 2019 which has the same major/minor as 2016, the code is failing to differentiate.
I figured this was the perfect time to try and identify a cleaner more generic solution, I say generic as I have no idea how or when these version numbers, specifically the build/revision will change, or when. I do not wish to find an update changes these numbers thus breaking the code all over again.
The best I have come up with some far is to extract OS version from the caption.