2

How can I invoke a remote command with powershell. Both computers are in the same network and I can have a Remote desktop connection from one to another.

EDIT: Both machine have Powershell V2, Windows Server 2008.
The task I try to accomplish is to restart Velocity on the second and third computer from the first one. Comandlet that is doing this is restart-cachehost.

Eugeniu Torica
  • 217
  • 2
  • 8

2 Answers2

5

You need use Powershell 2.0 with WinRM on either XP SP3, Win2k3 SP2, Vista, Windows 7 or Windows Server 2008.

You can get the latest build of Powershell 2.0 here: http://support.microsoft.com/kb/968929

And a quick start guide: http://blogs.msdn.com/powershell/archive/2008/12/24/configuring-powershell-for-remoting-part-1.aspx

Note the default ports of WinRM have changed: http://blogs.msdn.com/wmi/archive/2009/07/22/new-default-ports-for-ws-management-and-powershell-remoting.aspx

fenster
  • 454
  • 4
  • 13
1

After you have followed fenster's directions for setup, the actual remote execution command is simply:

Invoke-Command <remote_computer_name(s)> { Restart-CacheHost }

or if typing interactively, you can use the icm alias

$computers = 'server1','server2'
icm $computers { Restart-CacheHost }
user19468
  • 236
  • 1
  • 5