-
Notifications
You must be signed in to change notification settings - Fork 29
/
Get-DotNetVersions.ps1
47 lines (40 loc) · 971 Bytes
/
Get-DotNetVersions.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<#
.SYNOPSIS
Determine which .NET Core & Framework versions are installed.
.FUNCTIONALITY
DotNet
.LINK
Get-DotNetFrameworkVersions.ps1
.LINK
Use-Command.ps1
.EXAMPLE
Get-DotNetVersions.ps1
|Implementation Version
|-------------- -------
|.NET Framework 4.8.4084
|.NET Core 3.1.19
|.NET 5.0.10
#>
#Requires -Version 3
[CmdletBinding()] Param()
foreach($v in (Get-DotNetFrameworkVersions.ps1).GetEnumerator())
{
[pscustomobject]@{
Implementation = '.NET Framework'
Version = $v.Value
}
}
try
{
Use-Command.ps1 dotnet $env:ProgramFiles\dotnet\dotnet.exe -Fail
foreach($v in dotnet --list-runtimes)
{
$name,$version,$location = $v -split ' ',3
if($name -ne 'Microsoft.NETCore.App') {continue}
[pscustomobject]@{
Implementation = if($version -like '5.*'){'.NET'}else{'.NET Core'}
Version = $version
}
}
}
catch{Write-Warning "Unable to enumerate .NET versions: $_"}