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.
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.
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).
The WMI command line tool is a good choice:
You should look into the PSExec utility.
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.
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:
By default the credentials are that of the invoker, though other creds ca be specified as options.