Powershell Get-Process : Couldn't connect to remote machine

I had a similar error when I started to teach myself PS2 on Win7 client testing LocalHost. I resolved it by starting the Remote Registry service.


I finally gave up and wrote a new script that uses the following rather than calling Get-Process directly:

invoke-command -ComputerName Win2012r2 -ScriptBlock {param($procName) Get-Process -Name $processName} -ArgumentList $ProcName

-ComputerName in Get-Process uses RPC, not WinRM. WinRM is what uses 5985 and 5986, not RPC.

RPC ports are dynamic by default.

Check the "Get-Help" of Get-Process.

-ComputerName This parameter does not rely on Windows PowerShell remoting. You can use the ComputerName parameter of Get-Process even if your computer is not configured to run remote commands.

Invoke-Command DOES use WinRM. So when you changed your code to use Invoke-Command, your script started working.


Try using this instead:

get-wmiobject -class win32_process -computername pcname -filter "Name = 'procname'"