Users can install and run multiple versions of the .NET Framework on their computers. When you develop or deploy your app, you might need to know which .NET Framework versions are installed on the user’s computer.

To get an accurate list of the .NET Framework versions installed on a computer, you can view the registry or query the registry in code. Note that the .NET Framework consists of two main components, which are versioned separately:

  • A set of assemblies, which are collections of types and resources that provide the functionality for your apps. The .NET Framework and assemblies share the same version number.
  • The common language runtime (CLR), which manages and executes your app’s code. The CLR is identified by its own version number (see Versions and Dependencies).

To get an accurate list of the .NET Framework versions installed on a computer, you can view the registry or query the registry in code:

Read the full how to ‘determine Which .NET Framework Versions Are Installed’ on Docs.microsoft.com: How to: Determine Which .NET Framework Versions Are Installed

In PowerShell use the Get-ItemProperty cmdlet to get the installed .NET version:

(Get-ItemProperty "HKLM:Software\Microsoft\NET Framework Setup\NDP\v4\Full").Version

Check for a DWORD value named Release. The existence of the Release DWORD indicates that the .NET Framework 4.5 or newer has been installed on that computer.

(Get-ItemProperty "HKLM:Software\Microsoft\NET Framework Setup\NDP\v4\Full").Release

About .NET Framework versions: Did you know you can use the /clr parameter of AppCmd to target multiple ASP.NET CLR versions with AppCmd? CLR stands for Common Language Runtime. Pretty neat heh? :)

This may interest you:   Intrusion Detection with Windows Event ID's

Determine if .NET Core is installed, and its versions

If you want to know whether .NET Core is installed and, if yes, the available versions, you can use PowerShell. On Stack Overflow, Andriy Tolstoy lists a way to list the .NET Core runtimes available, and the SDK’s:

(dir (Get-Command dotnet).Path.Replace('dotnet.exe', 'shared\Microsoft.NETCore.App')).Name
(dir (Get-Command dotnet).Path.Replace('dotnet.exe', 'sdk')).Name

On Microsoft’s Technet Script Center gallery, you may find an additional How to determine ASP.NET Core installation on a Windows Server by PowerShell recipe contributed by OneScript Team:

$DotNETCoreUpdatesPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Updates\.NET Core" 
$DotNetCoreItems = Get-Item -ErrorAction Stop -Path $DotNETCoreUpdatesPath 
$NotInstalled = $True 
$DotNetCoreItems.GetSubKeyNames() | Where { $_ -Match "Microsoft .NET Core.*Windows Server Hosting" } | ForEach-Object { 
    $NotInstalled = $False 
    Write-Host "The host has installed $_" 
} 
If ($NotInstalled) { 
    Write-Host "Can not find ASP.NET Core installed on the host" 
}