How to Get .NET Version Using PowerShell?

If you’re a system administrator, developer, or IT professional working on Windows systems, then you might need to know which .NET versions are installed on your machine. PowerShell provides different ways to check the installed .NET Framework and .NET (Core/5+) versions.

In this tutorial, you’ll learn how to get the .NET version using PowerShell — covering both .NET Framework (Windows-only) and .NET (Core/5/6/7/8) (cross-platform).

Check .NET Framework Version Using PowerShell

The .NET Framework version is stored in the Windows Registry. You can query it directly using PowerShell.

Method 1: Using the Registry Path

Run the following PowerShell command to get the .NET framework version.

Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\' |
Get-ItemProperty -Name Release -ErrorAction SilentlyContinue |
Select-Object Release

This command retrieves the Release key value, which corresponds to a specific .NET Framework version.

Check out How to Install .NET Framework 3.5 Using PowerShell?

Method 2: Decode the Release Value

You can map the “Release” number to a version using the below PowerShell script:

$release = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\').Release

switch ($release) {
    { $_ -ge 533320 } { $version = "4.8.1"; break }
    { $_ -ge 528040 } { $version = "4.8"; break }
    { $_ -ge 461808 } { $version = "4.7.2"; break }
    { $_ -ge 461308 } { $version = "4.7.1"; break }
    { $_ -ge 460798 } { $version = "4.7"; break }
    { $_ -ge 394802 } { $version = "4.6.2"; break }
    { $_ -ge 394254 } { $version = "4.6.1"; break }
    { $_ -ge 393295 } { $version = "4.6"; break }
    default { $version = "Version 4.5 or earlier" }
}

Write-Output "Installed .NET Framework Version: $version"

Output Example:

Installed .NET Framework Version: 4.8.1

Here is the exact output in the screenshot below:

Get NET Version Using PowerShell

This script checks the registry, reads the release key, and translates it into a human-readable .NET Framework version.

Check out PowerShell New Line in String

Check .NET (Core/5/6/7/8) Version Using PowerShell

If you’re using .NET Core or later, you can use the dotnet CLI command directly from PowerShell.

Method 1: Using the dotnet Command

dotnet --list-sdks
dotnet --list-runtimes

Output Example:

6.0.412 [C:\Program Files\dotnet\sdk]
8.0.100 [C:\Program Files\dotnet\sdk]

This shows all SDKs and runtimes installed on your system.

Method 2: Get .NET Version Programmatically

You can also check the runtime version programmatically within PowerShell:

[System.Environment]::Version

This command returns the CLR version currently used by PowerShell — useful for quick checks.

Check out Check Who Modified a File Last in Windows Using PowerShell

Combine Both Checks into One Script

Here’s a PowerShell script that checks both .NET Framework and .NET Core versions at once:

Write-Host "=== Checking .NET Framework Version ==="
try {
    $release = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\').Release
    if ($release) {
        switch ($release) {
            { $_ -ge 533320 } { $version = "4.8.1"; break }
            { $_ -ge 528040 } { $version = "4.8"; break }
            { $_ -ge 461808 } { $version = "4.7.2"; break }
            default { $version = "4.7 or earlier" }
        }
        Write-Host "Installed .NET Framework Version: $version"
    } else {
        Write-Host "No .NET Framework 4.5 or later found."
    }
} catch {
    Write-Host "Unable to read .NET Framework version."
}

Write-Host "`n=== Checking .NET (Core/5/6/7/8) Versions ==="
try {
    dotnet --list-sdks
    dotnet --list-runtimes
} catch {
    Write-Host "dotnet CLI not found. .NET (Core/5+) may not be installed."
}

This script is ideal for system inventory reports or automated deployment scripts.

Troubleshooting

If the commands fail:

  • Ensure PowerShell is running as Administrator.
  • Verify that .NET Framework is installed (check via Control Panel → Programs → Turn Windows features on/off).
  • For .NET 5+, make sure the dotnet CLI is in your system PATH.

Conclusion

In this tutorial, we discussed how to get the .NET version using PowerShell. This will work in Windows servers or any other cross-platform systems.

  • Use registry queries for .NET Framework.
  • Use dotnet --list-sdks for .NET (Core/5/6/7/8).
  • Combine both checks for a complete system overview.

You may also like:

Leave a Comment

100 PowerShell cmdlets download free

100 POWERSHELL CMDLETS E-BOOK

FREE Download an eBook that contains 100 PowerShell cmdlets with complete script and examples.