34 lines
1.2 KiB
PowerShell
34 lines
1.2 KiB
PowerShell
|
function Get-DotNetVersion {
|
|||
|
<#
|
|||
|
.SYNOPSIS
|
|||
|
Returns the Registry Key Value and Friendly Version of the .NET Framework Which is Installed
|
|||
|
#>
|
|||
|
|
|||
|
[CmdletBinding()]
|
|||
|
Param()
|
|||
|
|
|||
|
$logLead = Get-LogLeadName
|
|||
|
|
|||
|
Write-Host "$logLead : Checking Registry for Version Key"
|
|||
|
$registryPath = "HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full"
|
|||
|
$netValueFromRegistry = Get-ItemProperty -Path $registryPath
|
|||
|
|
|||
|
if ($null -eq $netValueFromRegistry -or $null -eq $netValueFromRegistry.Release) {
|
|||
|
Write-Warning "$logLead : Unable to read the registry key from path $registryPath"
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
Write-Verbose "$logLead : Release subkey value read as $($netValueFromRegistry.Release)"
|
|||
|
|
|||
|
$friendlyVersion = $Global:DotNetVersionTranslation | Where-Object { $_.Key -match $netValueFromRegistry.Release } | Select-Object -First 1 -ErrorAction SilentlyContinue
|
|||
|
|
|||
|
if ($null -eq $friendlyVersion -or $null -eq $friendlyVersion.FriendlyVersion) {
|
|||
|
Write-Warning "$logLead : Unable to find a .NET version matching registry value $netValueFromRegistry.Release"
|
|||
|
return
|
|||
|
}
|
|||
|
|
|||
|
Write-Host "$logLead : FriendlyVersion Identified as $($friendlyVersion.FriendlyVersion)"
|
|||
|
|
|||
|
return $friendlyVersion
|
|||
|
}
|