I used script below, which I though was easy to update and using hash-tables in an effective way.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$version = (Get-ItemProperty "HKLM:SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full").Release | |
write-output "Current version: $($version)" | |
$versionTable = [ordered]@{ | |
".NET Framework 4.5" = 378389 | |
".NET Framework 4.5.1" = 378675 | |
".NET Framework 4.5.2" = 379893 | |
".NET Framework 4.6" = 393295 | |
".NET Framework 4.6.1" = 394254 | |
".NET Framework 4.6.2" = 394802 | |
".NET Framework 4.7" = 460798 | |
".NET Framework 4.7.1" = 461308 | |
".NET Framework 4.7.2" = 461808 | |
".NET Framework 4.8" = 528040 | |
} | |
$versionTable.GetEnumerator() | ForEach-Object { | |
if ($version -gt $_.value) { | |
$currentVersion = $_.key | |
} | |
} | |
write-output "Current version: $currentVersion" |
No comments:
Post a Comment