Run a command on multiple machines


  • 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 -p 8080 -m 1 -c 33904"

    Thanks folks.

    martedì 26 giugno 2012 06:41


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]

    • Proposto come risposta Just Karl martedì 26 giugno 2012 14:01
    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:

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


    • 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