4

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.

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}

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

Milto007
  • 68
  • 1
  • 1
  • 5

2 Answers2

8

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

  • Do you have any idea where I can change the relevant settings for this? – Milto007 Mar 12 '14 at 19:30
  • What would you like to change exactly? I don't think you can tell `Get-Process` to work directly over WinRM. You'll need to continue to use commands that sit on top of PowerShell Remoting (eg. `Invoke-Command`, PowerShell Workflow activities, etc.). If you really want the DCOM/RPC to work, you'll have to make sure your firewalls are configured to not block network traffic between hosts, or configure DCOM/RPC to use a static port (**NOT** recommended). –  Mar 12 '14 at 21:43
  • For what it's worth, I've found that running the following in an elevated PowerShell command prompt was sufficient for enabling the DCOM/RPC-based PowerShell Remoting commands: Set-NetFirewallRule -DisplayGroup "Remote Administration" -Enabled True – ZenoArrow Dec 23 '19 at 15:24
3

I ran across this error my self today, the solution in my case (I already had enabled port 5985) the problem occurred because of my firewall blocked port 445 (on the target).

As soon as this port was enabled I was able to use,

Get-Process -ComputerName dc01

and

Get-Service -ComputerName dc01

However I do recommend you read this page: https://www.grc.com/port_445.htm as it seems that some security issues may appear upon allowing this port toward the Internet.

My symptoms was exactly as OP descripes...