[D365] Check .NET version with PowerShell prior to PU37/10.0.13 release

As Microsoft states in the requirements for the PU37 / 10.0.13 release coming in October 2020, the Visual Studio tools require Microsoft .NET 4.7.2 runtime.

You can read the full details in a blog post from Microsoft here.

On-premise Tier1 environments (DevBoxes) need to be updated manually before installing PU37. To check if you already have .NET Framework version 4.7.2 runtime installed, you can use the following PowerShell script to speed up the process and maybe even scale the checks and run this on multiple environments:

$gpParams = @{
    Path        = 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full'
    ErrorAction = 'SilentlyContinue'
}
$release = Get-ItemProperty @gpParams | Select-Object -ExpandProperty Release

".NET Framework$(
    switch ($release) {
        ({ $_ -ge 528040 }) { ' 4.8'; break }
        ({ $_ -ge 461808 }) { ' 4.7.2'; break }
        ({ $_ -ge 461308 }) { ' 4.7.1'; break }
        ({ $_ -ge 460798 }) { ' 4.7'; break }
        ({ $_ -ge 394802 }) { ' 4.6.2'; break }
        ({ $_ -ge 394254 }) { ' 4.6.1'; break }
        ({ $_ -ge 393295 }) { ' 4.6'; break }
        ({ $_ -ge 379893 }) { ' 4.5.2'; break }
        ({ $_ -ge 378675 }) { ' 4.5.1'; break }
        ({ $_ -ge 378389 }) { ' 4.5'; break }
        default { ': 4.5+ not installed.' }
    }
)"

Example output from this script:

.NET Framework 4.8