Guest User

Untitled

a guest
Jul 20th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. #
  2. # Script to act based on the version of the Windows Server operating system it is run on
  3. # Pulled together from various sources online, nothing new here, just handy to use.
  4. # Currently not taking in to account workstation OSs
  5. #
  6. # J. S. Cooksey, 21/7/2018
  7. #
  8.  
  9. $version = [environment]::OSVersion.Version
  10. $version
  11.  
  12. if($version.Major -eq 10 -and $version.Minor -eq 0 -and $version.Build -ge 14393) { Write-Host "Windows 2016" }
  13. if($version.Major -eq 6 -and $version.Minor -eq 3 -and $version.Build -ge 9200) { Write-Host "Windows 2012R2" }
  14. if($version.Major -eq 6 -and $version.Minor -eq 2 -and $version.Build -ge 9200) { Write-Host "Windows 2012" }
  15. if($version.Major -eq 6 -and $version.Minor -eq 1 -and $version.Build -ge 7600) { Write-Host "Windows 2008R2" }
  16. if($version.Major -eq 6 -and $version.Minor -eq 0 -and $version.Build -ge 6002) { Write-Host "Windows 2008" }
Add Comment
Please, Sign In to add comment