Answer the question
In order to leave comments, you need to log in
Remote process termination on a group of servers via Powershell?
We need a script that will kill two processes on a certain group of servers. I got the following look:
$servers = @('srv-1','srv-2','srv-3')
Get-WmiObject Win32_Process -Filter "ExecutablePath LIKE '%process%'" `
-ComputerName $servers | Invoke-WmiMethod -Name Terminate
- Get-WmiObject : Сервер RPC недоступен.
Import-Module ActiveDirectory
$servers = (Get-ADComputer -Filter "Name -like 'srv-*'")
Get-WmiObject Win32_Process -Filter "ExecutablePath LIKE '%process%'" `
-ComputerName $servers | Invoke-WmiMethod -Name Terminate
Answer the question
In order to leave comments, you need to log in
Did you even look at the output of $servers in the first and second cases?
In the first you have names, in the second you have arrays.
You need to get server names from $servers in the second case.
For example, using -ComputerName $servers.Name
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question