Skip to content

Instantly share code, notes, and snippets.

@Kristinn-Stefansson
Kristinn-Stefansson / RemoveObsoleteDotnetCoreSDKs.ps1
Last active January 13, 2020 10:30
Remove Obsolete .NET Core SDKs - Leaving the one with the highest version number
$app = Get-WmiObject -Class Win32_Product | Where-Object {
$_.Name -match ".NET Core SDK"
} | ForEach-Object {
$isMatch = $_.Name -match "(\d+)\.(\d+)\.(\d+)"
$version = [System.Version]::Parse($Matches[0])
return [System.Tuple]::Create(($version),$_)
}
$installedVersions = @{}