Skip to content

Instantly share code, notes, and snippets.

@VimalShekar
Created January 12, 2018 15:57
Show Gist options
  • Save VimalShekar/8cfabf6361c6e313c5c829eb36c32035 to your computer and use it in GitHub Desktop.
Save VimalShekar/8cfabf6361c6e313c5c829eb36c32035 to your computer and use it in GitHub Desktop.
Checks if .NET framework v2.0 or newer is available on the machine using PowerShell
#-- Get the full script here:https://github.com/VimalShekar/PowerShell/blob/master/CheckDotNet.ps1
Function IsDotNet2orGreater {
# Check if .NET version 2.0 or greater is present
[bool] $bVersionPresent = $false
$Frameworks = Get-ChildItem "HKLM:\Software\Microsoft\NET Framework Setup\NDP"
foreach($FWver in $Frameworks) {
# if it matches v[0-9].+ and is >= v2.0 then requisite is met
if(($FWver.PSChildName -match "v[0-9].+") -and ($FWver.PSChildName -ge "v2.0"))
{
$bVersionPresent = $true
break
}
}
return $bVersionPresent
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment