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