Last active
May 10, 2021 12:49
-
-
Save PadreSVK/52d3c690db2d79128c91fecc26143a74 to your computer and use it in GitHub Desktop.
Script for testing installed .NET framework version, based on https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed#query-the-registry-using-code
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
Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -Recurse | Get-ItemProperty -Name version -EA 0 | Where { $_.PSChildName -Match '^(?!S)\p{L}'} | Select PSChildName, version |
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
$release = (Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full").Release | |
switch ($release) { | |
{ $_ -ge 528040 } { "4.8"; Break } | |
{ $_ -ge 461808 } { "4.7.2"; Break } | |
{ $_ -ge 461308 } { "4.7.1"; Break } | |
{ $_ -ge 460798 } { "4.7"; Break } | |
{ $_ -ge 394802 } { "4.6.2"; Break } | |
{ $_ -ge 394254 } { "4.6.1"; Break } | |
{ $_ -ge 393295 } { "4.6" ; Break } | |
{ $_ -ge 379893 } { "4.5.2"; Break } | |
{ $_ -ge 378675 } { "4.5.1"; Break } | |
{ $_ -ge 378389 } { "4.5" ; Break } | |
Default { "No 4.5 or later version detected $_" } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment