如何使用powershell远程调用一个commandlet

我如何使用PowerShell调用远程命令。 两台电脑都在同一个networking中,我可以从一个到另一个远程桌面连接。

编辑:这两台机器都有Powershell V2,Windows Server 2008。
我尝试完成的任务是从第一台计算机重新启动第二台和第三台计算机上的Velocity。 正在做这个restart-cachehostrestart-cachehost

您需要在XP SP3,Win2k3 SP2,Vista,Windows 7或Windows Server 2008上使用带有WinRM的Powershell 2.0。

您可以在这里获得最新版本的Powershell 2.0: http : //support.microsoft.com/kb/968929

快速入门指南: http : //blogs.msdn.com/powershell/archive/2008/12/24/configuring-powershell-for-remoting-part-1.aspx

注意WinRM的默认端口已经改变: http : //blogs.msdn.com/wmi/archive/2009/07/22/new-default-ports-for-ws-management-and-powershell-remoting.aspx

在按照设定的方向指示之后,实际的远程执行命令就是:

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

或者如果以交互方式打字,则可以使用icm别名

 $computers = 'server1','server2' icm $computers { Restart-CacheHost }