Forum Discussion
markgardenstate
Oct 22, 2024Copper Contributor
Old .NET versions automatic uninstallation/removal
Hello, How are you removing old versions of .NET from your devices? Is there a way to automate this? To better clarify our issue, please see the screenshot below. We just installed the la...
micheleariis
Oct 22, 2024Steel Contributor
markgardenstate Hi, you could use a powershell script distributed through Intune.
This script identifies all installed versions of .NET and removes those with versions lower than the one specified in $targetVersion. You can modify this script to suit your needs (for example, to target only specific runtimes such as Desktop Runtime).
$targetVersion = "6.0.35"
# Get all installed .NET runtimes
$installedDotNetVersions = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -like 'Microsoft .NET*' }
foreach ($dotNetVersion in $installedDotNetVersions) {
if ($dotNetVersion.Version -lt $targetVersion) {
Write-Host "Uninstalling $($dotNetVersion.Name) - Version $($dotNetVersion.Version)"
$dotNetVersion.Uninstall()
}
}
markgardenstate
Oct 22, 2024Copper Contributor