Checking if .NET framework is present in PowerShell

15 Sep 2017

Many a times, we have to check the version of Powershell to understand whether or not an assembly/namespace is available on the machine. Microsoft documentation recommends checking the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP registry key.

Here’s a function I wrote to find out if the version of .NET on the machine is greater than 2.0:

You can modify the version string to check the desired version. For example, I changed the string to look for 3.5 or later:

For version 4, the string becomes “v4”. You should also check the release version under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full – Release key

Refer: https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed

Hope this helps