Skip to content

Instantly share code, notes, and snippets.

@drmohundro
Last active May 12, 2022 13:28
Show Gist options
  • Save drmohundro/40244009b2f4f32b258b to your computer and use it in GitHub Desktop.
Save drmohundro/40244009b2f4f32b258b to your computer and use it in GitHub Desktop.
PowerShell script to return all installed .NET Framework versions.
<#
.Synopsis
Returns the install .NET Framework versions.
.Description
The script looks through the registry using the notes from the below
MSDN links to determine which versions of .NET are installed.
- https://msdn.microsoft.com/en-us/library/bb822049(v=vs.110).aspx
- https://msdn.microsoft.com/en-us/library/hh925568(v=vs.110).aspx
.Notes
AUTHOR: David Mohundro
#>
$ndpDirectory = 'hklm:\SOFTWARE\Microsoft\NET Framework Setup\NDP\'
if (Test-Path "$ndpDirectory\v2.0.50727") {
$version = Get-ItemProperty "$ndpDirectory\v2.0.50727" -name Version | select Version
$version
}
if (Test-Path "$ndpDirectory\v3.0") {
$version = Get-ItemProperty "$ndpDirectory\v3.0" -name Version | select Version
$version
}
if (Test-Path "$ndpDirectory\v3.5") {
$version = Get-ItemProperty "$ndpDirectory\v3.5" -name Version | select Version
$version
}
$v4Directory = "$ndpDirectory\v4\Full"
if (Test-Path $v4Directory) {
$version = Get-ItemProperty $v4Directory -name Version | select -expand Version
$version
}
@dragon788
Copy link

@tibileo You are correct that the devpack is probably the reason it's not showing up. You would probably need to use one of the folder search detection methods to find that version and have it check in the VS program folder since that is probably not a system-wide framework.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment