服务找不到资源 URI 和选择器标识的资源

服务找不到资源 URI 和选择器标识的资源

运行命令时winrm set -?,我可以看到以下如何禁用监听器的示例:

C:\Users\Administrator>winrm set -?
Windows Remote Management Command Line Tool

winrm set RESOURCE_URI [-SWITCH:VALUE [-SWITCH:VALUE] ...]
          [@{KEY="VALUE"[;KEY="VALUE"]}]
          [-file:VALUE]

Modifies settings in RESOURCE_URI using specified switches
and input of changed values via key-value pairs or updated
object via an input file.

Example: Disable a listener on this machine:
  winrm set winrm/config/Listener?Address=*+Transport=HTTPS @{Enabled="false"}

但是,当我运行与上面建议完全相同的命令时cmd,出现了错误:

C:\Users\Administrator>winrm set winrm/config/Listener?Address=*+Transport=HTTPS @{Enabled="false"}
WSManFault
    Message
        ProviderFault
            WSManFault
                Message = The WS-Management service cannot process the request. The service cannot find the resource identified by the resource URI and selectors.

Error number:  -2144108544 0x80338000
The WS-Management service cannot process the request. The service cannot find the resource identified by the resource URI and selectors.

在 PS 中我遇到了不同的错误:

PS C:\Users\Administrator> winrm set winrm/config/Listener?Address=*+Transport=HTTPS @{Enabled="false"}
Error: Invalid use of command line. Type "winrm -?" for help.

服务已启动并正在运行(test-wsman在 PS 中运行良好):

C:\Users\Administrator>winrm e winrm/config/Listener
Listener
    Address = *
    Transport = HTTP
    Port = 5985
    Hostname
    Enabled = true
    URLPrefix = wsman
    CertificateThumbprint
    ListeningOn = 10.152.26.30, 127.0.0.1, ::1,fe80::5efe:10.152.26.30%14, fe80::f9c5:141f:ff25:6253%12

我遗漏了什么?如何成功运行上述示例?

答案1

命令失败,因为Transport设置为HTTP,而不是HTTPS,这就是选择器Transport=HTTPS无法找到现有资源的原因。

因此命令应该是:

winrm set winrm/config/Listener?Address=*+Transport=HTTP @{Enabled="false"}

该命令应在命令提示符中执行(cmd.exe),因为它在 PS 中失败。

相关内容