If you are in a domain environment, you can also use:

winrs -r:PCNAME cmd

This will open a remote command shell.

Answer from user3744855 on Stack Overflow
Discussions

powershell 2.0 - How to execute a CMD file in remote computer - Stack Overflow
I am looking to execute a command in remote machine using invoke but the .cmd file will call for additional .vbs script. So i guess i may have to mention CScript if so how do i mention both cmd/c and More on stackoverflow.com
🌐 stackoverflow.com
TLDR of how to run commands on a remote Windows system? (and assorted questions)
PS-Remoting Enter-PSSession Invoke-Command More on reddit.com
🌐 r/PowerShell
13
13
October 16, 2021
How do you remotely use command prompt on another computer
How do you remotely use command prompt on another computer @Microsoft More on community.spiceworks.com
🌐 community.spiceworks.com
19
16
May 23, 2017
Running a .cmd file on a remote machine
What error are you getting when using invoke-command? Have you tried using PsExec? More on reddit.com
🌐 r/PowerShell
12
8
July 16, 2018
🌐
Spiceworks
community.spiceworks.com › software & applications
Run a command on a remote computer - Software & Applications - Spiceworks Community
March 4, 2016 - Ever needed to run a cmd on a remote computer such as gpupdate? this will show you how. This of course assumes you have admin access to the remote PC Step 1: Open an Administrative Command Prompt Open the Command Prompt windows.
🌐
Microsoft Learn
learn.microsoft.com › en-us › powershell › scripting › security › remoting › running-remote-commands
Running Remote Commands - PowerShell | Microsoft Learn
For example, the following command runs the DiskCollect.ps1 script on the remote computers, Server01 and Server02. Invoke-Command -ComputerName Server01, Server02 -FilePath C:\Scripts\DiskCollect.ps1 · Use the New-PSSession cmdlet to create a persistent session on a remote computer.
🌐
PDQ
pdq.com › blog › how-to-run-remote-commands
How to run PowerShell commands on remote computers | PDQ
April 30, 2025 - Enter PowerShell, which has made running commands on remote devices easier than ever. Using WinRM, sysadmins can leverage cmdlets like Enter-PSSession, New-PSSession, and Invoke-Command to manage and gather information from remote devices. In fact, many commands have built-in remoting using the -ComputerName parameter.
🌐
4sysops
4sysops.com › home › blog › vendors › three ways to run remote windows commands
Three ways to run remote Windows commands – 4sysops
October 11, 2019 - This is a classic command line ... on a remote computer/s and redirect the output to your local command shell. You will need to download PSExec to your computer. The next step would be to prepare a simple TXT file with the names of the computers on which you want to run the command, ...
Find elsewhere
🌐
ManageEngine
manageengine.com › remote-desktop-management › remote-command-prompt.html
Remote Command Prompt | Run commands on remote computer - ManageEngine Remote Access Plus
Hover over the computer name and click on System Manager -> Command Prompt. Method 2: Navigate to Tools-> System Manager -> Manager -> Command Prompt · If you have enabled user conformation then you will be able to access the terminal once the end user approves.
🌐
Stack Overflow
stackoverflow.com › questions › 19681913 › how-to-execute-a-cmd-file-in-remote-computer
powershell 2.0 - How to execute a CMD file in remote computer - Stack Overflow
param( [string]$ComputerName, [string]$User, [string]$pass ) Get-PSSEssion | Remove-PSSession $session = New-PSSession -ComputerName $ComputerName Invoke-Command -Session $session -ScriptBlock { param( [string]$ComputerName, [string]$Username, [string]$Password ) $net = new-object -ComObject WScript.Network $net.MapNetworkDrive("x:", "\\machinename\sharename", $false, $Username, $Password) cmd.exe /c "x:\c2.cmd" $net.RemoveNetworkDrive("x:") } -args $ComputerName, $User, $pass · This at least got the remote script to run and produced the expected output. (I emitted the computer name, user name, and file location.)
🌐
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.
🌐
Progress
progress.com › blogs › how-to-run-commands-on-remote-computers-with-powershell
How to Run Commands on Remote Computers with PowerShell
November 13, 2024 - PS C:\> hostname MACWINVM PS C:\> Invoke-Command -ComputerName SRV1 -ScriptBlock {hostname} SRV1 · You’ve now run your first remote command! Anything can go into the ScriptBlock parameter.
🌐
Reddit
reddit.com › r/powershell › tldr of how to run commands on a remote windows system? (and assorted questions)
r/PowerShell on Reddit: TLDR of how to run commands on a remote Windows system? (and assorted questions)
October 16, 2021 -

My experience in automation is limited to Linux (ssh, scp for file transfers). I'd like to a convenient way to run scripts/commands on a remote Windows PC, as well as transfer files, and it seems Powershell is the tool for that. I could install an SSH server, but if Powershell can achieve the same convenience without spending too much time learning, I'd prefer that, since I'd be able to use it on other Windows PCs without installing new software on them. My example scenario is:

  • MYDESKTOP: Windows 10 PC which has 3 files: data.csv, localscript.ps1, remotescript.ps1, IP 192.168.1.10.

  • MYTARGET: Windows 10 PC with local account, username alice, password mypassword, IP 192.168.1.25

I would like to:

  1. upload data.csv to MYTARGET's c:/data

  2. execute remotescript.ps1 locally on MYDESKTOP. This script contains a mixture of local commands to be executed on MYDESKTOP and remote commands to be executed on MYTARGET (eg Get-Process should return the processlist of MYDESKTOP, while a different Get-Process returns the process list of MYTARGET)

  3. execute localscript.ps1 entirely on MYTARGET. This script iterates over the local filesystem and does stuff, so not appropriate for being executed remotely if every iteration of a loop results in a network call.

...

$ $session = New-PSSession -ComputerName 192.168.1.25
New-PSSession : [192.168.1.25] Connecting to remote server 192.168.1.25 failed with the following error message : The WinRM client cannot process the request. Default authentication may be used with an IP address under the following conditions: the transport is HTTPS or the destination is in the TrustedHosts list, and explicit credentials are provided. Use winrm.cmd to configure TrustedHosts. Note that computers in the TrustedHosts list might not be authenticated. For more information on how to set TrustedHosts run the following command: winrm help config. For more information, see the about_Remote_Troubleshooting Help topic. At line:1 char:12
+ $session = New-PSSession –ComputerName 192.168.1.25
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException
+ FullyQualifiedErrorId : CannotUseIPAddress,PSSessionOpenFailed`

So already it's not as convenient as SSH, I gotta configure my PC to allow this outbound connection, and I guess I will also have to configure the remote PC to allow inbound connections.

Can someone give me the TLDR of how I should be doing this? I can start reading how to to allow IP connection and find the setting, and also allow username/password authentication, but should I even do this? If I open up the configuration and some malicious PC on the network starts to brute-force IP/password auth, will Windows automatically throttle/ban them?

This is gonna sound bad, but I'm not interested in learning more about Windows than the minimum I need to to achieve this goal, it doesn't really benefit me in the long term compared to the huge pile of things already on my to-learn list.

🌐
Reddit
reddit.com › r/powershell › running a .cmd file on a remote machine
r/PowerShell on Reddit: Running a .cmd file on a remote machine
July 16, 2018 -

I would like a PowerShell script to run on my local machine and launch a .cmd file on a remote server.

The .cmd file references f:\ and won’t run if it doesn’t have f: mapped how it expects.

I can’t edit the script that the .cmd file uses as it’s not mine I just perform some routine steps on the server that I would like to automate for myself.

I have been playing with invoke-command without success. Another issue is that the machine seems to have an old version of PowerShell, I’ll add what version it’s on when I’m back in the office.

🌐
AnyViewer
anyviewer.com › how-to articles › how to take control of another computer with cmd [2 methods]
How to Take Control of Another Computer with CMD [2 Methods]
December 13, 2024 - Part 4. Use PsExec with CMD to remotely control another computer · After you have finished the setup process, now you can start to use PsExec. Step 1. Download PsExec on the computer that will be running the remote commands. Step 2. Right-click on the ZIP file downloaded and select Extract All.
🌐
Active Directory Reporting Tool
activedirectorypro.com › psexec-run-commands-on-remote-computers
PsExec: Run Commands On Remote Computers - Active Directory Pro
November 12, 2025 - The -c option will copy a specified file to a remote computer and execute it. ... This example will open the command prompt on the remote computer, you can then run whatever command line you need.
🌐
SS64
ss64.com › nt › psexec.html
PsExec - Execute process remotely command - Windows CMD
-r The name of the remote service to create or interact with. -s Run remote process in the SYSTEM account (use with caution). -u user Specify a user name for login to remote computer(optional). -v Copy the specified file only if it has a higher version number or is newer than the one on the ...
🌐
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 - For example, the following command ... | measure Length -Sum).Sum/1MB)" Note. You can use the Invoke-Command cmdlet instead of PsExec to run commands remotely with PowerShell. The -c parameter allows you to specify the name of ...
🌐
Server Fault
serverfault.com › questions › 698644 › run-a-command-on-a-remote-windows-server-as-user
Run a command on a remote Windows Server as user - Server Fault
Enable Powershell remoting on the target server, then use Invoke-Command -ComputerName RemoteSeverName -ScriptBlock { some command } from Powershell on your computer. By default negotiate or kerberos authentication will be used so the command ...
🌐
Apple Support
support.apple.com › guide › remote-desktop › execute-commands-remotely-apd91b63ef0 › mac
Execute commands remotely with Remote Desktop - Apple Support
Using Remote Desktop, you can execute shell scripts on client computers. Shell scripts are files containing a collection of UNIX commands that are executed in sequence. The shell script must already be on the client computers, or you can use the Copy Items command to copy the script file to the client computers, then execute it using the Send UNIX Command. Run your script as root, or another user with root-level privileges, by entering “root” in the specified user field of the task dialog.