Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1011207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T09:12:00+00:00 2026-05-16T09:12:00+00:00

What would a PowerShell script be to return versions of the .NET Framework on

  • 0

What would a PowerShell script be to return versions of the .NET Framework on a machine?

My first guess is something involving WMI. Is there something better?

It should be a one-liner to return only the latest version for each installation of .NET [on each line].

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T09:12:01+00:00Added an answer on May 16, 2026 at 9:12 am

    If you’re going to use the registry you have to recurse in order to get the full version for the 4.x Framework. The earlier answers both return the root number on my system for .NET 3.0 (where the WCF and WPF numbers, which are nested under 3.0, are higher — I can’t explain that), and fail to return anything for 4.0 …

    EDIT: For .Net 4.5 and up, this changed slightly again, so there’s now a nice MSDN article here explaining how to convert the Release value to a .Net version number, it’s a total train wreck 🙁

    This looks right to me (note that it outputs separate version numbers for WCF & WPF on 3.0. I don’t know what that’s about). It also outputs both Client and Full on 4.0 (if you have them both installed):

    Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse |
    Get-ItemProperty -name Version,Release -EA 0 |
    Where { $_.PSChildName -match '^(?!S)\p{L}'} |
    Select PSChildName, Version, Release
    

    Based on the MSDN article, you could build a lookup table and return the marketing product version number for releases after 4.5:

    $Lookup = @{
        378389 = [version]'4.5'
        378675 = [version]'4.5.1'
        378758 = [version]'4.5.1'
        379893 = [version]'4.5.2'
        393295 = [version]'4.6'
        393297 = [version]'4.6'
        394254 = [version]'4.6.1'
        394271 = [version]'4.6.1'
        394802 = [version]'4.6.2'
        394806 = [version]'4.6.2'
        460798 = [version]'4.7'
        460805 = [version]'4.7'
        461308 = [version]'4.7.1'
        461310 = [version]'4.7.1'
        461808 = [version]'4.7.2'
        461814 = [version]'4.7.2'
        528040 = [version]'4.8'
        528049 = [version]'4.8'
    }
    
    # For One True framework (latest .NET 4x), change the Where-Object match 
    # to PSChildName -eq "Full":
    Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -Recurse |
      Get-ItemProperty -name Version, Release -EA 0 |
      Where-Object { $_.PSChildName -match '^(?!S)\p{L}'} |
      Select-Object @{name = ".NET Framework"; expression = {$_.PSChildName}}, 
    @{name = "Product"; expression = {$Lookup[$_.Release]}}, 
    Version, Release
    

    In fact, since I keep having to update this answer, here’s a script to generate the script above (with a little extra) from the markdown source for that web page. This will probably break at some point, so I’m keeping the current copy above.

    # Get the text from github
    $url = "https://raw.githubusercontent.com/dotnet/docs/master/docs/framework/migration-guide/how-to-determine-which-versions-are-installed.md"
    $md = Invoke-WebRequest $url -UseBasicParsing
    $OFS = "`n"
    # Replace the weird text in the tables, and the padding
    # Then trim the | off the front and end of lines
    $map = $md -split "`n" -replace " installed [^|]+" -replace "\s+\|" -replace "\|$" |
        # Then we can build the table by looking for unique lines that start with ".NET Framework"
        Select-String "^.NET" | Select-Object -Unique |
        # And flip it so it's key = value
        # And convert ".NET FRAMEWORK 4.5.2" to  [version]4.5.2
        ForEach-Object { 
            [version]$v, [int]$k = $_ -replace "\.NET Framework " -split "\|"
            "    $k = [version]'$v'"
        }
    
    # And output the whole script
    @"
    `$Lookup = @{
    $map
    }
    
    # For extra effect we could get the Windows 10 OS version and build release id:
    try {
        `$WinRelease, `$WinVer = Get-ItemPropertyValue "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" ReleaseId, CurrentMajorVersionNumber, CurrentMinorVersionNumber, CurrentBuildNumber, UBR
        `$WindowsVersion = "`$(`$WinVer -join '.') (`$WinRelease)"
    } catch {
        `$WindowsVersion = [System.Environment]::OSVersion.Version
    }
    
    Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -Recurse |
        Get-ItemProperty -name Version, Release -EA 0 |
        # For The One True framework (latest .NET 4x), change match to PSChildName -eq "Full":
        Where-Object { `$_.PSChildName -match '^(?!S)\p{L}'} |
        Select-Object @{name = ".NET Framework"; expression = {`$_.PSChildName}}, 
                    @{name = "Product"; expression = {`$Lookup[`$_.Release]}}, 
                    Version, Release,
        # Some OPTIONAL extra output: PSComputerName and WindowsVersion
        # The Computer name, so output from local machines will match remote machines:
        @{ name = "PSComputerName"; expression = {`$Env:Computername}},
        # The Windows Version (works on Windows 10, at least):
        @{ name = "WindowsVersion"; expression = { `$WindowsVersion }}
    "@
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to declare some integer constants in PowerShell. Is there any good
I would like to write powershell script to upgrade all working copies from 1.6
I have a Powershell script where I would like to create a generic List
I have a PowerShell script for which I would like to redirect the output
I have a Powershell script that uses System.Net.HttpWebRequest to communicate with a remote host.
I have a file that is tab delimited. I would like a powershell script
What would I need to do in order to run a PowerShell script in
I would like to declare the following type in my powershell script: Add-Type @'
I have a PowerShell script that I am debugging and would like to redirect
I'am tring to call a powershell script and pass through a parameter. I would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.