Skip to content

Instantly share code, notes, and snippets.

@kkbruce
Created July 29, 2019 03:14
Show Gist options
  • Select an option

  • Save kkbruce/b7ac4675f9bdee9a98cae9bb3468d4a8 to your computer and use it in GitHub Desktop.

Select an option

Save kkbruce/b7ac4675f9bdee9a98cae9bb3468d4a8 to your computer and use it in GitHub Desktop.
PowerShell: Determine .NET Framework Which Versions Are Installed
# Ref: https://docs.microsoft.com/zh-tw/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed
$netInfo = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\" -Name Release
$netVerKey = $netInfo.Release
if ($netVerKey -ge 528040) {
Write-Output "4.8 or later"
}
if ($netVerKey -ge 461808) {
Write-Output "4.7.2"
}
if ($netVerKey -ge 461308) {
Write-Output "4.7.1"
}
if ($netVerKey -ge 460798) {
Write-Output "4.7"
}
if ($netVerKey -ge 394802) {
Write-Output "4.6.2"
}
if ($netVerKey -ge 394254) {
Write-Output "4.6.1"
}
if ($netVerKey -ge 393295) {
Write-Output "4.6"
}
if ($netVerKey -ge 379893) {
Write-Output "4.5.2"
}
if ($netVerKey -ge 378675) {
Write-Output "4.5.1"
}
if ($netVerKey -ge 378389) {
Write-Output "4.5"
}
if ($netVerKey -lt 378389) {
Write-Output "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