Windows Management Instrumentation (WMI) 基礎結構的主要元件是系統中可管理實體的對象導向模型。 此模型符合桌面管理工作組(DMTF)維護的標準,稱為「通用資訊模型」(CIM)。 模型中的某些類別,例如 CIM_DataFile 或 Win32_Process,會直接對應至可管理的實體。 模型中的其他類別,例如 Win32_SystemServices,代表可管理實體之間的關聯性。 這些關聯性模型化類別稱為關聯類別。
使用 WMI 特定的查詢語言 WQL,您可以擷取代表可管理實體或關聯類別實例的類別實例。 但 WQL 是特定的實作。 它只適用於 DMTF 標準 (WMI) 的 Windows 實作。 此外,擷取關聯類別的 WQL 語法相當複雜。
Windows 遠端管理 (WinRM) 基礎結構提供絕佳的方法來利用 WMI 的功能。 舊版 WinRM 必須使用 WQL 來擷取關聯類別的實例。 WinRM 2.0 包含一項新功能,稱為透過關聯周游進行 DMTF 配置檔探索。 關聯周遊可讓使用者使用 DMTF CIM 系結規格中定義的標準篩選機制 AssociationFilter 方言來擷取關聯類別的實例。 如需關聯周遊的詳細資訊,請參閱 WS-Management CIM 系結規格 (Web服務管理)。
winrm 公用程式提供簡單的機制,以周遊適當的關聯並擷取裝置配置檔。
組態實作詳細數據
winrm 公用程式現在支持關聯要求的方言。 您可以使用 winrm 公用程式來指定 URI 或別名。
別名 | URI |
---|---|
協會 | https://www.dmtf.org/sites/default/files/standards/documents/DSP0227_1.0.0.pdf |
使用 AssociationFilter 方言擷取關聯類別的實例
winrm 公用程式可以擷取特定來源實例的 WMI 關聯類別實例。 下列命令示範如何使用 winrm 公用程式來擷取 Win32_Service 關聯類別的實例。 參數 “-associations” 必須用來傳回關聯類別。
winrm 列舉 wmicimv2/* -dialect:association -associations -filter:{object=win32_service?name=winrm;resultclassname=win32_dependentservice;role=dependent}
下列以文字為基礎的代碼段是上述命令的輸出:
Win32_DependentService
Antecedent
Address = https://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
ReferenceParameters
ResourceURI = http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_Service
SelectorSet
Selector: Name = RpcSs
Dependent
Address = https://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
ReferenceParameters
ResourceURI = http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_Service
SelectorSet
Selector: Name = WinRM
TypeOfDependency = null
Win32_DependentService
Antecedent
Address = https://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
ReferenceParameters
ResourceURI = http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_SystemDriver
SelectorSet
Selector: Name = HTTP
Dependent
Address = https://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
ReferenceParameters
ResourceURI = http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2/Win32_Service
SelectorSet
Selector: Name = WinRM
TypeOfDependency = null
使用 AssociationFilter 方言擷取相關聯類別的實例
winrm 公用程式可以擷取與特定來源實例相關聯的 WMI 類別實例。 下列命令示範如何使用 winrm 公用程式來擷取 Win32_Service 相關聯類別的實例。
winrm 列舉 wmicimv2/* -dialect:association -filter:{object=win32_service?name=winrm;associationclassname=win32_dependentservice;resultclassname=win32_service;resultrole=antecedent;role=dependent}
下列以文字為基礎的代碼段是上述命令的輸出:
Win32_Service
AcceptPause = false
AcceptStop = false
Caption = Remote Procedure Call (RPC)
CheckPoint = 0
CreationClassName = Win32_Service
Description = The RPCSS service is the Service Control Manager for COM and DCOM servers. It performs object activations requests, object exporter resolutions and distributed garbage collection for COM and DCOM servers. If this service is stopped or disabled, programs using COM or DCOM will not function properly. It is strongly recommended that you have the RPCSS service running DesktopInteract = false
DisplayName = Remote Procedure Call (RPC)
ErrorControl = Normal
ExitCode = 0
InstallDate = null
Name = RpcSs
PathName = C:\Windows\system32\svchost.exe -k rpcss
ProcessId = 716
ServiceSpecificExitCode = 0
ServiceType = Share Process
Started = true
StartMode = Auto
StartName = NT AUTHORITY\NetworkService
State = Running
Status = OK
SystemCreationClassName = Win32_ComputerSystem
SystemName = myComputer
TagId = 0
WaitHint = 0