user2042493
user2042493

Reputation: 21

Executing commands on command prompt of a remote computer

I need to execute the command :- Powermt display dev = all in the command prompt of a remote computer. How do I do that ?

Upvotes: 0

Views: 16073

Answers (2)

rojo
rojo

Reputation: 24466

Here's another alternative to try where psexec and powershell fail. It's convoluted and hackish, but at least it's something else to try. :)

Firstly, share a folder on your own machine. Make sure an account with admin rights on the remote machine has write access to this share you create. Then execute the following:

wmic /node:remoteComputerAddr /user:adminOnRemoteComputer /password:adminPassword process call create "cmd.exe /c powermt display dev=all >>\\localComputerAddr\shareName\results.txt"
@type "c:\local\path\to\share\results.txt"

Unfortunately, wmic doesn't show you the output of the process it creates. That's why you enable a share on your local workstation, then redirect the output from the remote command to your share.

More info.

Upvotes: 0

Keith Hill
Keith Hill

Reputation: 201632

If you have PowerShell 2.0 or higher on both computers and can enable remoting on the remote computer by execute Enable-PSRemoting -Force, then from an elevated/admin PowerShell prompt you can run:

Invoke-Command -ComputerName remotepcname -ScriptBlock { <commands to execute remotely> }

This will execute the commands remotely and return the results to the local computer.

Upvotes: 2

Related Questions