Skip to content
David Kittell
David Kittell

Application & System: Development / Integration / Orchestration

  • Services
    • Application Development
    • Online Application Integration
  • Code
  • Online Tools
  • Tech Support
David Kittell

Application & System: Development / Integration / Orchestration

PowerShell – Get .NET Framework / Core Version

Posted on June 3, 2020August 17, 2024 By David Kittell

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
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.

Related

Code PowerShell Windows Windows Reg Windows Server .net.net core.net core hosting.net frameworkversion

Post navigation

Previous post
Next post

Related Posts

Get Folder Size

Posted on December 14, 2013October 26, 2015

Function GetFolderSize(ByVal DirPath As String, _ Optional ByVal IncludeSubFolders As Boolean = True) As Long Dim lngDirSize As Long Dim objFileInfo As FileInfo Dim objDir As DirectoryInfo = New DirectoryInfo(DirPath) Dim objSubFolder As DirectoryInfo Try ‘add length of each file For Each objFileInfo In objDir.GetFiles() lngDirSize += objFileInfo.Length Next ‘call…

Read More

UNIX Bash – Domain List Get Whois Info

Posted on August 25, 2016September 2, 2016

If you manage a list of domains it’s sometimes helpful to have a script like this to check the information from time to time. I plan to clean this up in time but for now this works. First create a text file like below that has domains in it google.com…

Read More

DNN – Regain User Access

Posted on March 25, 2015October 26, 2015

If you have ever been locked out of a DNN site you maintain (must have SQL access) this solution will help. NOTE: If you don’t have SMTP settings configured this process will not help First find your “Portals” table and update “UserRegistration” = 2 Note: In the example below I…

Read More

Code

Top Posts & Pages

  • PowerShell - Rename Pictures to Image Taken
  • PowerShell - IIS Remove Site
  • Front Page
  • SQLite - Auto-Increment / Auto Generate GUID
  • PowerShell - FTP Upload Directory With Sub-Directories

Recent Posts

  • Javascript – Digital Clock with Style
  • BASH – Web Ping Log
  • BASH – Picture / Video File Name Manipulation
  • Mac OSX Terminal – Create SSH Key
  • Bash – Rename Picture

Top Posts

  • PowerShell - Rename Pictures to Image Taken
  • PowerShell - IIS Remove Site
  • SQLite - Auto-Increment / Auto Generate GUID
  • PowerShell - FTP Upload Directory With Sub-Directories
  • Raspberry Pi - Remove Default Apps
  • PowerShell - Change Windows CD/DVD Drive Letter
©2025 David Kittell | WordPress Theme by SuperbThemes