Created
November 17, 2021 22:08
-
-
Save lucaspimentel/90ba19ebe605428869a2d092b006dc45 to your computer and use it in GitHub Desktop.
Get installed .NET Framework version with PowerShell
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
$Versions = @( | |
@{ Release = 528040; Version = '4.8 or newer' } | |
@{ Release = 461808; Version = '4.7.2' } | |
@{ Release = 461308; Version = '4.7.1' } | |
@{ Release = 460798; Version = '4.7' } | |
@{ Release = 394802; Version = '4.6.2' } | |
@{ Release = 394254; Version = '4.6.1' } | |
@{ Release = 393295; Version = '4.6' } | |
@{ Release = 379893; Version = '4.5.2' } | |
@{ Release = 378675; Version = '4.5.1' } | |
@{ Release = 378389; Version = '4.5' } | |
) | |
$release = Get-ItemPropertyValue -Path 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full' -Name 'Release' | |
foreach ($version in $Versions) { | |
if ($release -as [int] -ge $version.Release) { | |
Write-Host "Detected .NET Framework $($version.Version)" | |
break | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment