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.

link|improve this question

50% accept rate
Can you be more specific about what you are trying to do? – Doug Chase Sep 3 '09 at 17:36
Is PowerShell installed on both computers? V1 or V2? – Doug Chase Sep 3 '09 at 17:37
feedback

2 Answers

up vote 5 down vote accepted

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

link|improve this answer
Thanks. I'll try it out. – Jenea Sep 4 '09 at 7:03
feedback

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 }
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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