Running .exe on multiple machines

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Matt Bloomfield Matt Bloomfield 3 weeks, 2 days ago.

  • Author
  • #54774
    Profile photo of JayBlanck

    Hey All,

    New to PS and looking for a script to remotely run a .exe on multiple machines. The first part is to get the list of computers and the second to run the .exe on each. Do I need to use the foreach command possibly? I don't get an error when I run it, but I'm not getting a log file that the .exe should create once it runs.

    $computers = Get-Content "C:\temp\servers.txt"
    Invoke-Command -ComputerName $computers -filePath C:\temp\file.exe
  • #54787
    Profile photo of Matt Bloomfield
    Matt Bloomfield

    The FilePath parameter is used to specify a PowerShell script. I'm surprised you're not getting an error to that effect.

    This should work:

    Invoke-Command $computers {c:\temp\file.exe}

    As you're running the command on a remote computer, c:\temp\file.exe must exist on that machine.

You must be logged in to reply to this topic.