If you’re building a PowerShell script and you would like to know at what .NET version a computer is… It’s kinda tricky a think… The installed .NET versions are written in the registry, but not particularly in a way that’s easy to read/script for us.

Registry .NET version

The following code returns a string with the version of the highest installed .NET version.

Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -recurse | Get-ItemProperty -name Version -ErrorAction SilentlyContinue | Sort-Object Version -Descending | Select -First 1 | %{ $_.Version }