Get-Process 到远程计算机不起作用,但 Invoke-Command 起作用 [英] Get-Process to remote computer doesn't work but Invoke-Command does

查看:37
本文介绍了Get-Process 到远程计算机不起作用,但 Invoke-Command 起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 2 台运行 Windows Server 2012 R2 的服务器.其中之一是托管运行 Windows 7 32 位的虚拟机,我正在尝试使用另一台服务器查看虚拟机当前正在运行的进程.

I have a 2 servers running Windows Server 2012 R2. One of them is hosting a virtual machine running Windows 7 32-bit, and I am trying to use the other server to view the currently running processes of the virtual machine.

我必须使用 Enable-PSRemoting -SkipNetworkProfileCheck 才能正常工作.我还必须将这些计算机添加到彼此的 TrustedHosts 列表中.

I had to use Enable-PSRemoting -SkipNetworkProfileCheck for anything to work. I also had to add the computers to each others TrustedHosts lists.

Get-Process -ComputerName VM01

将返回无法连接到远程机器".然而,

will return a "Couldn't connect to remote machine". However,

Invoke-Command -ComputerName VM01 -ScriptBlock {Get-Process}

工作正常.使用 Invoke-Command 和使用带有 ComputerName 参数的 Get-Process 有什么区别?如果它很重要,我也可以毫无问题地使用 Enter-PSSession

works just fine. What is the difference between using Invoke-Command and using the Get-Process with a ComputerName argument? In case it is important, I can also use Enter-PSSession without any problems

推荐答案

Get-Process 可能使用 DCOM/RPC 远程处理协议而不是 Windows 远程管理 (WinRM),这就是 PowerShell Remoting (例如 Invoke-Command) 使用.如果您有阻止 DCOM/RPC 的防火墙,那么我可以看到带有 -ComputerName 参数的 Get-Process 将如何失败.借助 PowerShell 远程处理(通过 WinRM),您只需打开 TCP 5985 (HTTP) 和 TCP 5986(HTTPS,可选).

Get-Process probably uses the DCOM/RPC remoting protocol instead of Windows Remote Management (WinRM), which is what PowerShell Remoting (eg. Invoke-Command) uses. If you have a firewall blocking DCOM/RPC, then I could see how Get-Process with the -ComputerName parameter would fail. With PowerShell Remoting (via WinRM), all you need to do is open up TCP 5985 (HTTP) and TCP 5986 (HTTPS, optional).

这篇关于Get-Process 到远程计算机不起作用,但 Invoke-Command 起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆