Posted On February 7, 2020

PowerShell: Check DotNet Framework on Windows

kimconnect 0 comments
blog.KimConnect.com >> Codes >> PowerShell: Check DotNet Framework on Windows
function checkDotNetVersions{
# General info:
# - Powershell 2.0 latest SSL version support is TLS 1.2
# - Powershell always uses DotNet framework to make HTTPS calls
# - DotNet 4.5 is required for TLS1.2
# Get .NET Versions
$translation = @{
378389 = [version]'4.5'
378675 = [version]'4.5.1'
378758 = [version]'4.5.1'
379893 = [version]'4.5.2'
393295 = [version]'4.6'
393297 = [version]'4.6'
394254 = [version]'4.6.1'
394271 = [version]'4.6.1'
394802 = [version]'4.6.2'
394806 = [version]'4.6.2'
460798 = [version]'4.7'
460805 = [version]'4.7'
461308 = [version]'4.7.1'
461310 = [version]'4.7.1'
461808 = [version]'4.7.2'
461814 = [version]'4.7.2'
528040 = [version]'4.8'
528049 = [version]'4.8'
}

$hive=Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -Recurse
$hiveObjects=$hive|Get-ItemProperty -name Version, Release -EA 0 |Where-Object { $_.PSChildName -match '^(?!S)\p{L}'}
$dotNetObjects=$hiveObjects |Select-Object @{name = ".NET Framework"; expression = {$_.PSChildName}},
@{name = "Product"; expression = {$translation[$_.Release]}},
Version, Release
return $dotNetObjects;
}
checkDotNetVersions

Sample Output:

PS C:\Windows\system32> checkDotNetVersions

.NET Framework Product Version Release
-------------- ------- ------- -------
v2.0.50727 2.0.50727.4927
v3.0 3.0.30729.4926
Windows Communication Foundation 3.0.4506.4926
Windows Presentation Foundation 3.0.6920.4902
v3.5 3.5.30729.4926
Client 4.8 4.8.03761 528049
Full 4.8 4.8.03761 528049
Client 4.0.0.0

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

PowerShell: Add and Remove a Registry Key

How to Add a Registry Key # Add New Registry Key $regHive='REGISTRY::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM' $keyname='OleDbTimeout' $value=600 Set-ItemProperty…

Kerberos “Second Hop” Problem

Issue Sometimes, there's a need to run WinRM into a "Jump Box" (trusted host in…

PowerShell: Get Available RAM Slots

# getRamSlotsAvailable.ps1 $computername=$env:computername function getRamSlotsAvailable{ param($computername=$env:computername) write-host "Computer name: $computerName" $slots = Get-WmiObject -Class "win32_PhysicalMemoryArray"…
Other project: DragonCoin.com