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.

2
  • Can you be more specific about what you are trying to do? Commented Sep 3, 2009 at 17:36
  • Is PowerShell installed on both computers? V1 or V2? Commented Sep 3, 2009 at 17:37

2 Answers 2

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

0
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 } 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.