I have diffrent donet versions and application on many machines, how can i uninstall these without doing it one by one.

Esther Barhalibirhu 0 Reputation points
2024-11-14T13:56:50.4433333+00:00

I have different donet versions and application on many machines, how can i uninstall these without doing it one by one.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,981 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jiachen Li-MSFT 32,851 Reputation points Microsoft Vendor
    2024-11-15T01:43:16.8633333+00:00

    Hi @Esther Barhalibirhu ,

    You can create a PowerShell script to detect and uninstall .NET versions across multiple machines. If you have access to each machine remotely, you can run the script on all of them.

    # List of remote machines
    $machines = @("Machine1", "Machine2", "Machine3")
    
    # Loop through each machine
    foreach ($machine in $machines) {
        Invoke-Command -ComputerName $machine -ScriptBlock {
            # Get a list of all .NET SDKs installed
            $dotnetSDKs = Get-ChildItem -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" |
                          Where-Object { $_.GetValue("DisplayName") -match "Microsoft .NET SDK" }
    
            # Uninstall each SDK found
            foreach ($sdk in $dotnetSDKs) {
                $uninstallString = $sdk.GetValue("UninstallString")
                if ($uninstallString) {
                    # Run the uninstallation command
                    Start-Process -FilePath $uninstallString -ArgumentList "/quiet" -NoNewWindow -Wait
                }
            }
        }
    }
    
    

    Best Regards.

    Jiachen Li


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.