Last active
October 30, 2016 09:55
-
-
Save cezarypiatek/280262b7d6c3c1ac2c49 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-KeyPropertyValue($key, $property) | |
{ | |
if($key.Property -contains $property) | |
{ | |
Get-ItemProperty $key.PSPath -name $property | select -expand $property | |
} | |
} | |
function Get-VersionName($key) | |
{ | |
$name = Get-KeyPropertyValue $key Version | |
$sp = Get-KeyPropertyValue $key SP | |
$install = Get-KeyPropertyValue $key Install | |
$languages = (Get-Languages $key.PSPath) -join ", " | |
$languagePackInfo = if($languages){"Language packs: $languages"}else{""} | |
if($sp) | |
{ | |
"$($_.PSChildName) $name SP $sp $languagePackInfo" | |
}else{ | |
"$($_.PSChildName) $name $languagePackInfo" | |
} | |
} | |
function Get-Languages($versionDir){ | |
Get-ChildItem $versionDir |? {$_.PSChildName -match "\d{4}"} |% {[System.Globalization.CultureInfo]::GetCultureInfo([int]$_.PSChildName).Name} | |
} | |
function Get-FrameworkVersion{ | |
dir "hklm:\SOFTWARE\Microsoft\NET Framework Setup\NDP\" |? {$_.PSChildName -like "v*"} |%{ | |
if( $_.Property -contains "Version") | |
{ | |
Get-VersionName $_ | |
}else{ | |
$parent = $_ | |
Get-ChildItem $_.PSPath |%{ | |
$versionName = Get-VersionName $_ | |
"$($parent.PSChildName) $versionName" | |
} | |
} | |
} | |
$v4Directory = "hklm:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" | |
if(Test-Path $v4Directory) | |
{ | |
$v4 = Get-Item $v4Directory | |
$version = Get-KeyPropertyValue $v4 Release | |
$languages = (Get-Languages $v4Directory) -join ", " | |
$languagePackInfo = "Language packs: $languages" | |
switch($version){ | |
378389 {".NET Framework 4.5 $languagePackInfo"; break;} | |
378675 {".NET Framework 4.5.1 installed with Windows 8.1 or Windows Server 2012 R2 $languagePackInfo"; break;} | |
378758 {".NET Framework 4.5.1 installed on Windows 8, Windows 7 SP1, or Windows Vista SP2 $languagePackInfo"; break;} | |
379893 {".NET Framework 4.5.2 $languagePackInfo"; break;} | |
{ 393295, 393297 -contains $_} {".NET Framework 4.6 $languagePackInfo"; break;} | |
{ 394254, 394271 -contains $_} {".NET Framework 4.6.1 $languagePackInfo"; break;} | |
{ 394802, 394806 -contains $_} {".NET Framework 4.6.2 $languagePackInfo"; break;} | |
} | |
} | |
} | |
Export-ModuleMember -Function Get-FrameworkVersion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment