First I want to apologize I don’t remember where I found the original script but I have added some additional version numbers
function Get-NET4Version () {
$netRegKey = Get-Childitem "HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full"
$release = $netRegKey.GetValue("Release")
$releases = @(
@{id = ""; value = "Microsoft .NET Framework 4 not installed" },
@{id = "378389"; value = "Microsoft .NET Framework|4.5" },
@{id = "378675"; value = "Microsoft .NET Framework|4.5.1" }
@{id = "379893"; value = "Microsoft .NET Framework|4.5.2" },
@{id = "393295"; value = "Microsoft .NET Framework|4.6" },
@{id = "394254"; value = "Microsoft .NET Framework|4.6.1" },
@{id = "394802"; value = "Microsoft .NET Framework|4.6.2" },
@{id = "460798"; value = "Microsoft .NET Framework|4.7" },
@{id = "461814"; value = "Microsoft .NET Framework|4.7" },
@{id = "461308"; value = "Microsoft .NET Framework|4.7.1" }
@{id = "461808"; value = "Microsoft .NET Framework|4.7.2" }
@{id = "528040"; value = "Microsoft .NET Framework|4.8" }
@{id = "528209"; value = "Microsoft .NET Framework|4.8" }
@{id = "528049"; value = "Microsoft .NET Framework|4.8" }
)
foreach ($framework in $releases) {
if ($framework.id -eq $release) {
$version = $framework.value
}
}
return "$($env:COMPUTERNAME)|$version"
}
function Get-NETCoreHostingVersion () {
$DotNETCoreUpdatesPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Updates\.NET Core"
try {
$DotNetCoreItems = Get-Item -ErrorAction Stop -Path $DotNETCoreUpdatesPath
$DotNetCoreItems.GetSubKeyNames() | Where-Object { $_ -Match "Microsoft .NET Core.*Windows Server Hosting" } | ForEach-Object {
#$version = $_
$version = $_.replace("Microsoft .NET Core ", "")
$version = $version.replace(" - Windows Server Hosting (x86)", "")
return "$($env:COMPUTERNAME)|Microsoft .NET Core Windows Server Hosting|$version"
}
}
catch {
return "$($env:COMPUTERNAME)|ASP.NET Core is not installed on the host"
}
}
Clear-Host
Get-NETCoreHostingVersion
Get-NET4Version
Originally Posted on June 3, 2020
Last Updated on August 17, 2024
Last Updated on August 17, 2024
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.