Author Posts

September 30, 2016 at 8:10 pm

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

October 1, 2016 at 12:11 pm

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.