One way would be with PsExec:

psexec \\server_ip "path_to_where_the_file_should_go/file.exe"

Other methods include remote Powershell, telnet, SSH.

Answer from simlev on Stack Exchange
Top answer
1 of 5
29

Did you try using the -ArgumentList parameter:

invoke-command -ComputerName studio -ScriptBlock { param ( $myarg ) ping.exe $myarg } -ArgumentList localhost   

http://technet.microsoft.com/en-us/library/dd347578.aspx

An example of invoking a program that is not in the path and has a space in it's folder path:

invoke-command -ComputerName Computer1 -ScriptBlock { param ($myarg) & 'C:\Program Files\program.exe' -something $myarg } -ArgumentList "myArgValue"

If the value of the argument is static you can just provide it in the script block like this:

invoke-command -ComputerName Computer1 -ScriptBlock { & 'C:\Program Files\program.exe' -something "myArgValue" } 
2 of 5
3

Are you trying to pass the command line arguments to the program AS you launch it? I am working on something right now that does exactly this, and it was a lot simpler than I thought. If I go into the command line, and type

C:\folder\app.exe/xC:\folder\file.txt

then my application launches, and creates a file in the specified directory with the specified name.

I wanted to do this through a Powershell script on a remote machine, and figured out that all I needed to do was put

$s = New-PSSession -computername NAME -credential LOGIN
    Invoke-Command -session $s -scriptblock {C:\folder\app.exe /xC:\folder\file.txt}
Remove-PSSession $s

(I have a bunch more similar commands inside the session, this is just the minimum it requires to run) notice the space between the executable, and the command line arguments. It works for me, but I am not sure exactly how your application works, or if that is even how you pass arguments to it.

*I can also have my application push the file back to my own local computer by changing the script-block to

C:\folder\app.exe /x"\\LocalPC\DATA (C)\localfolder\localfile.txt"

You need the quotes if your file-path has a space in it.

EDIT: actually, this brought up some silly problems with Powershell launching the application as a service or something, so I did some searching, and figured out that you can call CMD to execute commands for you on the remote computer. This way, the command is carried out EXACTLY as if you had just typed it into a CMD window on the remote machine. Put the command in the scriptblock into double quotes, and then put a cmd.exe /C before it. like this:

cmd.exe /C "C:\folder\app.exe/xC:\folder\file.txt"

this solved all of the problems that I have been having recently.

EDIT EDIT: Had more problems, and found a much better way to do it.

start-process -filepath C:\folder\app.exe -argumentlist "/xC:\folder\file.txt"

and this doesn't hang up your terminal window waiting for the remote process to end. Just make sure you have a way to terminate the process if it doesn't do that on it's own. (mine doesn't, required the coding of another argument)

Discussions

run a remote EXE with argument, from a user share but have the command run on the server that the share resides on, not local machine.
The script runs but nothing happens on teh remote server. checked powershell logs and see nothing in particular. weird. ... Well, then let's add a bit of logging. Just change the two "Out-File" cmdlets in the script block to use a directory on the SERVERNAME machine. $Directory = "d:\rootfilepath" Invoke-Command -Computer SERVERNAME -ScriptBlock {Try{ Start-Process -NoNewWindow -FilePath "D:\incomingdatafiles\DataFileLoader\DataFileLoader\DataFileLoader.exe... More on learn.microsoft.com
🌐 learn.microsoft.com
5
0
c# - I want to run .exe as a webserver on a remote host - Stack Overflow
You can execute any Windows PowerShell command on one or more remote computers using the WS-Management protocol. On distant computers, you can create permanent connections, begin interactive sessions, and execute scripts. To run a command on one or more computers, use the Invoke-Command cmdlet ... More on stackoverflow.com
🌐 stackoverflow.com
command prompt - How to run exe on remote PC using psexec - Stack Overflow
Not sure if you are restricted to only CMD. invoke-command -computername SYSDES208 -scriptblock { D:\TestFile.exe } If you are using a domain account or have the exact same account on the remote machine you shouldn't need to enter credentials as powershell will use the cred of the local user. ... Sign up to request clarification or add additional context in comments. ... you need to add credential as well to run ... More on stackoverflow.com
🌐 stackoverflow.com
run a remote EXE with argument, from a user share but have the command run on the server that the share resides on, not local machine.
The script runs but nothing happens on teh remote server. checked powershell logs and see nothing in particular. weird. ... Well, then let's add a bit of logging. Just change the two "Out-File" cmdlets in the script block to use a directory on the SERVERNAME machine. $Directory = "d:\rootfilepath" Invoke-Command -Computer SERVERNAME -ScriptBlock {Try{ Start-Process -NoNewWindow -FilePath "D:\incomingdatafiles\DataFileLoader\DataFileLoader\DataFileLoader.exe... More on docs.microsoft.com
🌐 docs.microsoft.com
5
0
August 3, 2020
🌐
Stack Overflow
stackoverflow.com › questions › 69512839 › i-want-to-run-exe-as-a-webserver-on-a-remote-host
c# - I want to run .exe as a webserver on a remote host - Stack Overflow
On distant computers, you can create permanent connections, begin interactive sessions, and execute scripts. To run a command on one or more computers, use the Invoke-Command cmdlet provided by Microsoft..
🌐
SS64
ss64.com › nt › psexec.html
PsExec - Execute process remotely command - Windows CMD
PsExec can be used to start GUI applications, but in that case the GUI will appear on the remote machine. ... Input is passed to the remote system when you press the enter key - typing Ctrl-C will terminate the remote process. PsExec does not require you to be an administrator of the local filesystem, with the correct password psexec will allow UserA to run commands as UserB - a Runas replacement. If you kill a PsExec process, you might also need to manually remove the background service: sc.exe \\workstation64 delete psexesvc
Find elsewhere
🌐
TheITBros
theitbros.com › windows › miscellaneous top posts: › using psexec to run commands on remote computers – theitbros
Using PsExec to Run Commands On Remote Computers – TheITBros
March 5, 2026 - Any command that you type in the console will be executed on the remote lon-srv01 computer. ... By default, PsExec uses the current user to connect to the remote machine. You can set alternative remote user credentials in PsExec: psexec.exe \\lon-srv01 -u user -p password cmd.exe · You can even use PsExec to run PowerShell commands remotely.
🌐
Petri
petri.com › home › how to run commands and programs remotely using psexec
How to Run Commands and Programs Remotely Using PsExec | Petri
July 29, 2025 - Although PsExec’s prowess and reputation stem from running commands on remote systems, you can run commands locally if you wish. If you don’t include the ‘computer’ switch, PsExec will execute the command on your local system. Here is an example. ... As you can see, a new session of cmd.exe is started using the ‘-s’ switch which opens it using the local SYSTEM account.
Top answer
1 of 3
4

You created a pssession to the remote computer but didn't use it. Your Start-Process was run on the computer hosting the script. You need to use Enter-PSSession since it:

Starts an interactive session with a remote computer.

Once you are in a session then you do not need to run the WMI commands remotely. You can run them like you were running on the server directly. Borrowing from the example on MSDN

The first command uses the Enter-PSSession cmdlet to start an interactive session with Server01, a remote computer. When the session starts, the command prompt changes to include the computer name.

PS C:\> Enter-PSSession -Computer Server01
[Server01]: PS C:\>

The second command gets the Windows PowerShell process and redirects the output to the Process.txt file. The command is submitted to the remote computer, and the file is saved on the remote computer.

[Server01]: PS C:\> Get-Process Powershell > C:\ps-test\Process.txt

Don't forget to call Exit-PSSession when you are done.


Invoke-Command

If you didn't want to use pssessions then you could also you Invoke-Command on the remote machine as well. You already are trying to do this with your last lines of code.

Invoke-Command -ComputerName $computer -ScriptBlock {Start-Process "bagel.exe"}

If you do go down this path be aware of scoping issues and look up how to pass arguments to the scriptblock.

I am not sure why yours is not working. Perhaps you have some errors being suppressed? I would try something simpler for testing. Is your application GUI based? It might not work when run like this. Try something like ipconfig and see what the results are.


I would also consider a while loop with a timeout condition while you are waiting for the process to terminate/start on the remote machine. That was you can account for failures better instead of assuming that 10 seconds is enough.

2 of 3
1

I think you've a problem with your local/remote execution.

(Get-WmiObject win32_process -ComputerName $computer -Credential $mycreds | ?{ $_.ProcessName -match "Workbench3.helper" }).Terminate()

Above line returns all processes from the remote computer to your local computer. Than you're fitering the returned process-objects on your LOCAL machine, and call Terminate() on your LOCAL machine. I would suggest you use the following line instead:

Invoke-command -session $pers -ScriptBlock { (Get-WmiObject win32_process -ComputerName $computer -Credential $mycreds | ?{ $_.ProcessName -like"*Workbench3.helper*" }).Terminate()}

This should kill the Workbench3 process(es). I used the like operator to make filtering less strict.

After that, you can reuse the session stored in $pers to start the process again.

Invoke-command -session $pers -scriptblock {Start-Process -filepath "C:\Program Files (x86)\Company Security\Workbench3 Helper\WorkBench3.Helper.exe" -Wait }

I additionally used the -Waitswitch. The switch forces Start-Process to wait for the programm to be started (and return afterwards).

When doing remote operations I would always suggest to perform these operations via Invoke-Commandand not via the -ComputerName parameters of the several commands. Invoke-Command uses WS-MAN via HTTP(S), while the remote-implemenation of commands offering the -ComputerNameparameter differ in implementation from cmdlet to cmdlet. This advantage of invoke-commandmakes it easier to configure e.g. firewalls.

Hope that helps.

🌐
Reddit
reddit.com › r/powershell › running local .exe and arguments on remote pc's
r/PowerShell on Reddit: Running local .exe and arguments on remote pc's
June 1, 2022 -

Hi folks!

I'm trying to run an .exe to remove Adobe from numerous PC's (using the Adobe Creative Cloud Cleaner Tool) and it has been suggested by others that I could run a remote command to do this. I'd like to run this .exe with the xml argument from my local machine, using a user account which has local admin rights on all the other PCs.

Invoke-Command -ComputerName PCNAME-23, PCNAME-24 -FilePath C:\AdobeCreativeCloudCleanerTool.exe -ArgumentList "--cleanupXML=cleanup.xml"

I got as far to write the above, but Invoke-Command only seems to want to use .ps1 files, rather than .exe's. Is there any slight adjustments that could solve this for me? I'm a bit of a newbie, so any help would be massively appreciated.

🌐
PowerShell Forums
forums.powershell.org › powershell help
Running an executable on a remote computer using Invoke-Command - PowerShell Help - PowerShell Forums
January 17, 2019 - I am a newbie to Powershell. I have been trying to run an executable using the invoke-command using ScriptBlock and trying it with just -FilePath. I get the file copied to the remote computer and directory but then I get errors. I am trying to use switches with the executable /install /quiet ...
🌐
Business.com
business.com › home › technology › it management
Remotely Invoke Applications With PowerShell
January 23, 2026 - To do this, use a combination of two cmdlets: Invoke-Command to enable you to run a command on the remote computer and Start-Process to execute the process.
🌐
Active Directory Reporting Tool
activedirectorypro.com › psexec-run-commands-on-remote-computers
PsExec: Run Commands On Remote Computers - Active Directory Pro
November 12, 2025 - Here I’m running ipconfig on pc1 and srv-vm1. ... To kill a process on a remote computer use the commands below. You first need to get the process PID, this can be done with the tasklist command. ... Find the process PID number then use taskkill to kill the process. ... In this example, I’m installing 7zip on the remote computer PC1. The installation file has been copied to the remote computer. You can also use the -c option to copy a file and execute it.
🌐
Microsoft Community Hub
techcommunity.microsoft.com › microsoft community hub › communities › products › powershell › windows powershell
Running an exe install remotely | Microsoft Community Hub
August 8, 2022 - I want to have a script run through an OU and install an exe on each server but I'm having difficulty putting everything together. What am I doing wrong? Is there a better way to script this? This is what I currently have. $cmd = '\\server\share\install.exe' $parm1 = '/S /Token=' $parm2 = 'Test$' foreach($server in Get-ADComputer -Filter * -SearchBase "OU=Servers,DC=Domain,DC=Local") { Invoke-Command -ComputerName $server $cmd $parm1"'"$parm2"'" }