Get-Process无法连接到远程计算机

时间:2017-11-16 19:51:19

标签: powershell

我最近尝试使用powershell设置脚本,以便我可以监视远程计算机上的关键进程。

Get-Process -ComputerName myremotepc myprocess

这给了我以下错误。

Get-Process : Couldn't connect to remote machine.
At line:1 char:1
+ Get-Process -ComputerName myremotepc myprocess
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Get-Process],     InvalidOperationException
+ FullyQualifiedErrorId :     System.InvalidOperationException,Microsoft.PowerShell.Commands.GetProcessCommand

检查后是否启用了正确的服务。我仍然无法连接。

3 个答案:

答案 0 :(得分:1)

请注意,明确指出不需要启用PSRemoting。差异可能是您提升的提示或防火墙例外。

PS C:\> Get-Help Get-Process -Parameter 'ComputerName'

-ComputerName <String[]>
    Specifies the computers for which this cmdlet gets active processes. The default is the local computer.

    Type the NetBIOS name, an IP address, or a fully qualified domain name (FQDN) of one or more computers. To specify the local computer, type the computer name, a dot (.), or localhost.

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

    Required?                    false
    Position?                    named
    Default value                None
    Accept pipeline input?       True (ByPropertyName)
    Accept wildcard characters?  false

答案 1 :(得分:0)

为了使其正常工作,我必须按照以下答案在远程计算机上启动 Remote Registry 服务:

https://serverfault.com/a/717837/240263

答案 2 :(得分:-2)

我遇到了以下链接。

https://social.technet.microsoft.com/Forums/projectserver/en-US/f58c4ca9-0708-401a-8d66-86195006174d/simple-remote-command-getprocess-how-to-get-the-two-machines-talking-to-each-other?forum=winserverpowershell

在该页面上,有一位用户建议在PowerShell中为要连接的PC启用远程处理。

# Enable Remoting
Enable-PSRemoting

在一个提升的提示中在powershell中运行它后,我可以查询远程PC。

Handles  NPM(K)    PM(K)      WS(K) VM(M)   CPU(s)     Id ProcessName
-------  ------    -----      ----- -----   ------     -- -----------
811      38        27696      28568   233              3196 explorer