Saturday, March 12, 2011

Well, it's one line in PowerShell, assuming you have all 50 computers in comp.txt in current folder, one workstation per line:

Invoke-WmiMethod -ComputerName (Get-Content comp.txt) -Class Win32_Process -Name Create -ArgumentList 'netsh interface tcp set global autotuninglevel=disabled'

You may have to elevate powershell first. If your account is not admin on remote side you will probably need -Credential there as well.

I've just tested it and it worked as expected. :)




Can't you use the invoke-wmi cmdlet to perform that operation?

$cred = get-credential
$exe = "notepad"
$computers = get-content "listOfComputers.txt"
foreach($computer in $computers)
{
Invoke-WmiMethod -Name Create -Class Win32_Process -Namespace root\cimv2 -ArgumentList $exe -credentials $cred -ComputerName $computer | out-null
}

out-null surpresses the output of the create method.
by default you would receive the process information if the command executed successfully.

No comments:

Mimmo97 Blog Archive