none
Run a command on multiple machines

    Domanda

  • How can i run this simple command on multiple machines?No worry for the tools availability as it already been copied to all the machines.

      "ipxfer -s 10.50.25.185 -p 8080 -m 1 -c 33904"

    Thanks folks.

    martedì 26 giugno 2012 06:41

Risposte

Tutte le risposte

  • Hi,
    Check this cmdlet: Invoke-Command
    or try use PsExec tool from sysinternals.

    Get-help Invoke-Command -Examples
    
    psexec [\\computer[,computer2[,...] | @file][-u user [-p psswd]][-n s][-l][-s|-e][-x][-i [session]][-c [-f|-v]][-w directory][-d][-<priority>][-a n,n,... ] cmd [arguments]
    

    martedì 26 giugno 2012 07:44
  • Thank you. Is that the invoke-command will only work if we enable winRM on each destination computers? If yes, this is tedious.
    mercoledì 27 giugno 2012 00:33
  • Invoke-command use winRM protocol, but you dont need enable it on each machine you may use GPO policy for this:
    http://msdn.microsoft.com/en-us/library/aa384372(VS.85).aspx

    Alternative you may use PsExec tool or WMI to create process on remote machine (it use RPC no winRM):

    [wmiclass]$wmi="\\$ComputerName\root\cimv2:win32_process"
    $wmi.Create($yourCommand)

    • Contrassegnato come risposta herngyih giovedì 28 giugno 2012 00:31
    mercoledì 27 giugno 2012 05:50
  • PSExec works well.  Except for the @file tricky part.  You need to add `@file in powershell. This has been resolved.  Saved me lot of time from login to hundred of PCs. Thanks alot.
    giovedì 28 giugno 2012 00:30