Monday, January 20, 2020

How to list installed .NET Framework versions using PowerShell

Getting installed .NET Framework versions is (surprisingly) not a simple task. On this post, let's try to address that.
When .NET developers have to fix problems on a remote server that requires knowing which versions of the .NET Framework are installed, they'll be frustrated. Unfortunately, the Redmond folks made it unnecessarily complicated to know the installed versions of the .NET Framework on a  Windows box.

.NET Core on the other side, does it well via the .NET Core CLI. But for those of us still on the .NET Framework, what can we do? The official documentation, describes multiple options including accessing the registry, using PowerShell and building a C# application.

The simplest and fastest solution is obviously PowerShell. So let's keep it simple, shall we?

The Solution

The solution lies on this simple PowerShell script:

Simplifying Further

Ok, but let's assume that we're on a remote server. Opening chrome and downloading this script might not be ideal. Could we somehow script this out?

Yes, by using PowerShell's Invoke-WebRequest (PowerShell's curl), we could make it a one-liner so that we don't have to even open a browser and download that script from GitHub. Here is it:
Invoke-WebRequest -Uri -OutFile list-dotnet-frameworks.ps1; .\list-dotnet-frameworks.ps1
Hope it helps!

See Also

For more posts on .NET Core, please click here.
Do you have any comment or suggestion about this post? Please contact me @BrunoHilden