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

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.

share|improve this question
    
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

2 Answers 2

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

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

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