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: Enable TLS 1.2 on legacy servers

# Enable TLS 1.2 on legacy servers function enableTls12{ $windowsVersionNumber=[System.Environment]::OSVersion.Version.Major; #$windowsName=(Get-CimInstance -ClassName Win32_OperatingSystem).Caption; #The term…

Linux: MySql Docker Container – Export database

# Set VariablessqlContainer="mysql-server"userName=bruceleepassword=chucknorrisdatabaseName=kimconnect# Run mysql inside containerdocker exec -it  $sqlContainer mysql -u$userName --password='$password'show databases;# Execute mysqldumpdocker exec $sqlContainer /usr/bin/mysqldump…

Puppet Client Server Lab Setup

Server # Setup client machine name sudo vim /etc/hosts ## Insert this line ## xx.xx.xx.xx…
Other project: DragonCoin.com