Hello,
I came across this link for removing all versions of Java regardless of how many older versions are installed through the TechNet site. I am hoping someone can help modify it. Here is what I need it to do. I have a txt file with the computer names that I need to remove java from. If I can have the script go through that txt file and remove it from all the computers on the list it would be awesome. Is there a way to do it?
$computers = Get-Content -path "C:\users\walter\desktop\test java.txt" foreach ($computer in $computers) { $RegUninstallPaths = @( 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall') $VersionsToKeep = @('Java 7 Update 67') Get-WmiObject Win32_Process | Where {$_.ExecutablePath -like '*Program Files\Java\*'} | Select @{n='Name';e={$_.Name.Split('.')[0]}} | Stop-Process -Force get-process -Name *iexplore* | Stop-Process -Force -ErrorAction SilentlyContinue $UninstallSearchFilter = { ($_.GetValue('DisplayName') -like '*Java*') -and (($_.GetValue('DisplayName') -eq 'Oracle') -or ($_.GetValue('DisplayName') -eq 'Sun Microsystems, Inc.')) -and ($VersionsToKeep -notcontains $_.GetValue('DisplayName'))} foreach ($Path in $RegUninstallPaths) { if (Test-Path $Path) { Get-ChildItem $Path | Where $UninstallSearchFilter | Foreach { Start-Process 'C:\Windows\System32\msiexec.exe' "/x $($_.PSChildName) /qn" -Wait} } } New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT | Out-Null $ClassesRootPath = “HKCR:\Installer\Products” Get-ChildItem $ClassesRootPath | Where { ($_.GetValue('ProductName') -like '*Java*7*') -or ($_.GetValue('ProductName') -like “Java*6*”)} | Foreach {Remove-Item $_.PsPath -Force -Recurse} $JavaSoftPath = 'HKLM:\SOFTWARE\JavaSoft' if (Test-Path $JavaSoftPath) { Remove-Item $JavaSoftPath -Force -Recurse } Remove-Item $env:Programfiles\Java\ -Force -Recurse }