Need to uninstall Java with SCCM deployment

TechUST 601 Reputation points
2025-02-11T04:06:55.6233333+00:00

In my environment, I need to uninstall Java from machines. Multiple versions of Java are installed, but I want to deploy a single script that can uninstall Java regardless of its version. Could you please suggest a PowerShell script to achieve this objective?

Windows for business | Windows Server | User experience | PowerShell
Microsoft Security | Intune | Other
Microsoft System Center | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AllenLiu-MSFT 49,311 Reputation points Microsoft External Staff
    2025-02-11T05:36:05.1833333+00:00

    Hi, @TechUST

    Thank you for posting in Microsoft Q&A forum.

    To uninstall Java from machines using a PowerShell script, you can utilize the Get-WmiObject cmdlet to find all versions of Java installed on the system and then uninstall them. Below is a sample PowerShell script that achieves this:

    # Get all installed Java products
    $javaProducts = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -like "Java*" }
    
    # Uninstall each Java product found
    foreach ($product in $javaProducts) {
        $product.Uninstall()
    }
    

    This script retrieves all installed products whose names start with "Java" and uninstalls each one. You can deploy this script using SCCM to remove Java from the target machines.


    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 "Add comment".

    1 person found this answer helpful.

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.