Checking Operating System Version

by Apr 4, 2017

Here is a simple and fast way of checking the operating system version:

 
PS C:\> [Environment]::OSVersion


Platform ServicePack Version      VersionString                    
-------- ----------- -------      -------------                    
 Win32NT             10.0.14393.0 Microsoft Windows NT 10.0.14393.0
 

So now it’s a snap checking whether a script runs on the intended operating system. To check for Windows 10, for example, try this:

 
PS C:\> [Environment]::OSVersion.Version.Major -eq 10

True
 

Twitter This Tip! ReTweet this Tip!