Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

How do I script remote commands on other Windows computers from a Windows computer?

E.g., on *nix-*nix networks, I can do ssh wu@otherbox foo, and provided the keys are set up correctly, foo runs and the ssh client returns the return code.

share|improve this question
    
I'm not able to comment yet, or else I would drop this in there: 3rding Psexec, with the added comment that the EULA can be accepted via the command line argument /accepteula –  NPS Oct 3 '11 at 19:28

4 Answers 4

psexec - http://technet.microsoft.com/en-us/sysinternals/bb897553

PsExec is a light-weight telnet-replacement that lets you execute processes on other systems, complete with full interactivity for console applications, without having to manually install client software.

Another option is to write a powershell or vbscript (using WMI).

share|improve this answer

The WMI command line tool is a good choice:

wmic.exe /node:somecomputer process call create "c:\bin\uphclean\uphclean.exe -install"
share|improve this answer

You should look into the PSExec utility.

share|improve this answer

There is another way if you're looking for a scripting approach. This can be done via powershell in addition to psexec and wmic. Remote powershell works only for Windows 7 and probably Vista, and definitely for Server 2008.

invoke-command -computername YourTarget01 -scriptblock {
    $Object=get-something $Wibble
    $Data1=$Object.method
    }

To use this requires WinRM to be turned on and configured on the target machine. This stuff can be pushed via GPO so you don't have to configure it by hand everywhere. Handy for mass deployments. For complex actions, it's a good idea to create a single session object so you're not spinning up a new one each time you hit the machine:

$Session=new-pssession -ComputerName YourTarget01
invoke-command -Session $Session -Scriptblock { }

By default the credentials are that of the invoker, though other creds ca be specified as options.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.