c++ - 从 Linux OMI (omicli) 到 Windows WMI 的连接失败并出现 DMTF 相关错误

标签 c++ linux winrm wsman cim

我正在 CentOs 上用 C++ 实现 OMI 客户端,以与 Windows WMI 进行通信 我已在 Linux CentOS 7 上安装 OMI 并尝试连接到 Windows 7 使用 OMI 提供的示例实用程序。

引用:https://github.com/Microsoft/omi

还在 Windows 上配置 WINRM 以接收基本身份验证调用。

我无法让示例正常工作。出现以下错误:

root@LinuxMachine bin]# ./omicli --auth Basic --hostname WinMachine.TEST.COM -u admin -p adminpassaword ei root/cimv2 Win32_Environment --port 5985
./omicli: result: MI_RESULT_FAILED
./omicli: result: ERROR_INTERNAL_ERROR: The WS-Management service cannot process the request. A DMTF resource URI was used to access a non-DMTF class. Try again using a non-DMTF resource URI.

下面是目标机器的WINRM配置供引用

C:\Windows\system32>winrm 获取 winrm/config

Config
    MaxEnvelopeSizekb = 150
    MaxTimeoutms = 60000
    MaxBatchItems = 32000
    MaxProviderRequests = 4294967295
    Client
        NetworkDelayms = 5000
        URLPrefix = wsman
        AllowUnencrypted = true [Source="GPO"]
        Auth
            Basic = true [Source="GPO"]
            Digest = true [Source="GPO"]
            Kerberos = true [Source="GPO"]
            Negotiate = true [Source="GPO"]
            Certificate = true
            CredSSP = true [Source="GPO"]
        DefaultPorts
            HTTP = 5985
            HTTPS = 5986
        TrustedHosts
    Service
        RootSDDL = O:NSG:BAD:P(A;;AG;;;BA)S:P(AU;FA;GA;;;WD)(AU;SA;GWGX;;;WD)
        MaxConcurrentOperations = 4294967295
        MaxConcurrentOperationsPerUser = 15
        EnumerationTimeoutms = 60000
        MaxConnections = 25
        MaxPacketRetrievalTimeSeconds = 120
        AllowUnencrypted = true
        Auth
            Basic = true [Source="GPO"]
            Kerberos = true [Source="GPO"]
            Negotiate = true [Source="GPO"]
            Certificate = false
            CredSSP = true [Source="GPO"]
            CbtHardeningLevel = Relaxed
        DefaultPorts
            HTTP = 5985
            HTTPS = 5986
        IPv4Filter = *
        IPv6Filter = *
        EnableCompatibilityHttpListener = false
        EnableCompatibilityHttpsListener = false
        CertificateThumbprint
    Winrs
        AllowRemoteShellAccess = true
        IdleTimeout = 180000
        MaxConcurrentUsers = 5
        MaxShellRunTime = 2147483647
        MaxProcessesPerShell = 15
        MaxMemoryPerShellMB = 150
        MaxShellsPerUser = 5

我遗漏了什么明显的东西吗?非常感谢任何使示例正常工作的帮助。

最佳答案

我也遇到过类似的问题。我已经通过升级服务器上的 power-shell 版本解决了这个问题。

Windows 7 默认显示使用 powershell 版本 2.0。

PS C:\> test-wsman <clientName>

wsmid           : http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd
ProtocolVersion : http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd
ProductVendor   : Microsoft Corporation
ProductVersion  : OS: 0.0.0 SP: 0.0 Stack: 2.0

默认情况下,CIM session 使用 WSMAN 协议(protocol),特别是较新版本的协议(protocol)。 这不适用于运行 powershell 2.0 版或根本没有 powershell 的计算机。 升级您的以解决此问题。

引用网址https://mcpmag.com/articles/2013/05/07/remote-to-second-powershell.aspx了解更多详情。

关于c++ - 从 Linux OMI (omicli) 到 Windows WMI 的连接失败并出现 DMTF 相关错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51934395/

相关文章:

windows - WS-Management 服务找不到请求的证书

windows - 你如何关闭 Pywinrm session ?

windows - Ansible - 管理 Windows 2003 和 WinRM 连接超时

c++ - 用 C++ 编写 Mac OS X 应用程序的完整解决方案

c++ - 使用 GCC 4.8 编译时无法对 vector 执行 std::swap

linux - [[ bash 条件表达式中的语法错误

linux - Haskell OpenAl 没有声音

c++ - 在 COM 对象上使用 std::map?

c++ - Bin Packing 算法 - 实际变体

linux - 目录中包含一个 .csv 文件和所有其他文件