Skip to content

Instantly share code, notes, and snippets.

@janv8000
Forked from drmohundro/Get-FrameworkVersions.ps1
Last active May 24, 2018 14:25
Show Gist options
  • Save janv8000/b29d94b7c00dc0116c8f97eeec6323e2 to your computer and use it in GitHub Desktop.
Save janv8000/b29d94b7c00dc0116c8f97eeec6323e2 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
}
if (Test-Path "$ndpDirectory\v4\Full") {
$release = Get-ItemProperty "$ndpDirectory\v4\Full" -name Release | select -expand Release
$version = Get-ItemProperty "$ndpDirectory\v4\Full" -name Version | select -expand Version
Write-Host $version '(Release:' $release')'
}
@janv8000
Copy link
Author

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