Hi again!
In my tasks, I often face up with problem to determine latest version of the .Net Framework, which is installed on the machine. This problem could be resolved very easily using Powershell.
The main idea is to check Windows Registry – .Net Framework writes own info to the special folder there. Knowing where located specific version could help us:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
function getDotNetVersion{ $ndpDirectory = 'hklm:\SOFTWARE\Microsoft\NET Framework Setup\NDP\' $version = $null if (Test-Path "$ndpDirectory\v2.0.50727") { $version = Get-ItemProperty "$ndpDirectory\v2.0.50727" -name Version | select Version } if (Test-Path "$ndpDirectory\v3.0") { $version = Get-ItemProperty "$ndpDirectory\v3.0" -name Version | select Version } if (Test-Path "$ndpDirectory\v3.5") { $version = Get-ItemProperty "$ndpDirectory\v3.5" -name Version | select Version } $v4Directory = "$ndpDirectory\v4\Full" if (Test-Path $v4Directory) { $version = Get-ItemProperty $v4Directory -name Version | select -expand Version } return $version } |
So, as you see, it’s pretty simple đŸ™‚ In case of not-installed .Net Framework we will get null result.
That’s it! đŸ™‚