Winrm允许我通过WS-MAN协议查询WMI而不是DCOM。 但是,在DCOM实现中,我可以检索我查询的各个类的各种属性的数据types。 但是,如果我使用winrm,我只需要返回值。 有什么办法来查询数据types?
例如c:> winrm enum wmicimv2 / * -dialect:wql -filter:“Select * FROM Win32_ComputerSystem”
会返回类似的东西
<wsman:Results xmlns:wsman="http://schemas.dmtf.org/wbem/wsman/1/wsman/results"> <p:Win32_ComputerSystem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_ComputerSystem" xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common" xsi:type="p:Win32_ComputerSystem_Type" xml:lang="en-US"> <p:AdminPasswordStatus>3</p:AdminPasswordStatus> <p:AutomaticManagedPagefile>true</p:AutomaticManagedPagefile> <p:AutomaticResetBootOption>true</p:AutomaticResetBootOption> <p:AutomaticResetCapability>true</p:AutomaticResetCapability> <p:BootOptionOnLimit xsi:nil="true"/><p:BootOptionOnWatchDog xsi:nil="true"/> <p:BootROMSupported>true</p:BootROMSupported> <p:BootupState>Normal boot</p:BootupState> .....
但是,正如您所看到的那样,数据types不在那里。 我知道数据types,因为这是一个标准的Win32对象。 模式是在线的,我可以静态地找出来。 但是,可能有自定义的类。 DCOM WMI方法允许我查询属性并找出更多关于它们的细节,比如它们的数据types,以及它们是否是数组。 我可以通过winrm / wsman做同样的事情吗? 我知道这可以通过PowerShell来完成。 我正在寻找winrm / wsman方法,而不是powershell
谢谢
您可以通过多种方式来完成这一操作,它将返回一个包含所有已定义数据types的对象。 然后您可以获取这个对象并获取每个值的数据types。
$WMI = get-wmiobject -class Win32_ComputerSystem -ComputerName <RemoteComputer> $WMI.PSObject.Members | where membertype -match "Property"
这给你的WMI对象,你可以从那里做你想做的。 $ WMI.psobject.Members枚举每个值,并允许您循环查看每个对象。
Get-WmiObject不使用WS-Management连接到远程计算机,因此不需要远程计算机configurationWS-Management。 这里使用DCOM。 如果你想使用WinRM,你可以使用
$Results = Invoke-Command -scriptblock { get-wmiobject -class Win32_ComputerSystem } -computerName <ComputerName>
这个variables将是一个Deserialized.System.Management.ManagementObject#root \ cimv2 \ Win32_ComputerSystem,但有一些添加的属性。