-2

I need to uninstall Java from several computers in my network. After almost all day of Googling it seems the best way to do this is with a Powershell script. I found one that I have tested on a few computers that works pretty well but I'm not a PS wiz and am unsure of how to loop it through a list of computers. I'd like to just have a txt document with a list of computer names - one name per line. Is this easy to do? Anyone know how to do this? Thanks in advance.

Here is the ps script obtained from here.

yagmoth555
  • 16,758
  • 4
  • 29
  • 50
Tyler Miranda
  • 73
  • 2
  • 9

1 Answers1

2

Here are two ways:

Import-Module ActiveDirectory
Foreach($C In Get-ADComputer -Filter *)
{
    Invoke-Command -ComputerName $C.Name { Do-Something }
}

Foreach($C In Get-Content C:\ComputerList.txt)
{
    Invoke-Command -ComputerName $C { Do-Something }
}

Where Do-Something is probably an msiexec.exe command or something. This requires a couple of things to work. WinRM (aka Powershell Remoting) to be enabled on the computers, and network connectivity for RPC.

Ryan Ries
  • 55,481
  • 10
  • 142
  • 199