检查远程计算机中的WinRM服务

Kiq*_*net 7 powershell .net-4.0 powershell-remoting winrm

我见过很棒的文章
PowerShell 2.0远程指南:第8部分 - 远程处理方案和故障排除
http://www.ravichaganti.com/blog/?p=1181

我有这个问题:我在域中有两台计算机,在网络中.

第一次测试OK:从域中的计算机远程连接到域中的计算机

COMPANY_DOMAIN\desmonitor是域用户.
域名COMPANY_DOMAIN
计算机:iis01

PS C:\ Users\myUser> Enter-PSSession -Computername iisw01 -Credential COMPANY_DOMAIN\desmonitor
[desiisw01]:PS C:\ Users\desmonitor\Documents> exit

第二次测试错误::使用本地管理员用户从域中的计算机远程连接到域中的计算机

iis01\instalador是机器iis01
计算机的本地用户:iis01

PS C:\ Users\myUser> Enter-PSSession -Computername iis01 -Credential iis01\instalador Enter-PSSession:连接到远程服务器失败,并显示以下错误消息:WinRM客户端无法处理请求.

在使用COMPANY_DOMAIN\desmonitor的终端服务器(远程桌面)的机器ii01中,我打开PS控制台并执行

PS C:\ Users\desmonitor> winrm quickconfig
WinRM已设置为在此计算机上接收请求.
WinRM已经设置为在此计算机上进行远程管理.
PS C:\ Users\desmonitor>

然后,我再试一次,但我得到同样的错误:

PS C:\ Users\myUser> Enter-PSSession -Computername iis01 -Credential iis01\instalador Enter-PSSession:连接到远程服务器失败,并显示以下错误消息:WinRM客户端无法处理请求.

使用此命令:

PS C:\ Users\myUser> Set-Item WSMan:\ localhost\Client\TrustedHosts -Value"*" - Force PS C:\ Users\myUser>

现在,我可以访问:

PS C:\ Users\myUser> Enter-PSSession -Computername iis01 -Credential iis01\instalador [iiw01]:PS C:\ Users\instalador\Documents> $ Host

Name             : ServerRemoteHost
Version          : 1.0.0.0
InstanceId       : 6905896f-e6c7-4603-82f0-20183f71b1ec
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : es-ES
CurrentUICulture : es-ES
PrivateData      :
IsRunspacePushed :
Runspace         :
Run Code Online (Sandbox Code Playgroud)

在我的公司,有许多计算机连接到iis01.

每个计算都需要执行命令,将远程计算机添加到本地计算机的可信主机列表中?

我有几个问题¿

如何在本地计算机中获取有关TrustedHosts(WSMan:\ LocalHost\Client)的列表?
如何知道计算机中是否启用了WinRM服务?
如何知道WinRM服务是否在计算机上运行?
如何知道WinRM是否设置为在计算机中接收请求?
如何知道WinRM是否已设置为在此计算机上进行远程管理?

rav*_*nth 27

Q1.如何在本地计算机中获取有关TrustedHosts(WSMan:\ LocalHost\Client)的列表?

Get-Item WSMan:\localhost\Client\TrustedHosts
Run Code Online (Sandbox Code Playgroud)

Q2/Q3.如何知道计算机中是否启用了WinRM服务?如何知道WinRM服务是否在计算机上运行?

Get-Service -ComputerName server01 -Name winrm | Select Status
Run Code Online (Sandbox Code Playgroud)

Q4.如何知道WinRM是否设置为在计算机中接收请求?对此不太确定,但我会证实.一种查找方法是查看是否列出了客户端端口.但是,就像我说的那样,我可以证实这一点.

Get-ChildItem WSMan:\localhost\Client\DefaultPorts
Run Code Online (Sandbox Code Playgroud)

Q5.如何知道WinRM是否已设置为在此计算机上进行远程管理?

您应该能够列出监听器.

Get-ChildItem WSMan:\localhost\Listener
Run Code Online (Sandbox Code Playgroud)

如果您在此处看不到任何内容,则表示您未设置WSMAN传入连接.