支持所有版本。
WMI每个大类是继承于它的父类,你刚好可以用上这点。先看看这行:
PS> Get-WmiObject -Class Win32_Printer
接着下面将可以从WMI发现更多printers,它是通过更多的类继承同时我们可以看看它的树结构:
PS> Get-WmiObject -Class Win32_Printer | Select-Object -ExpandProperty __derivation -First 1 CIM_Printer CIM_LogicalDevice CIM_LogicalElement CIM_ManagedSystemElement
所以当你不是指定打印机继承类,而是更广泛的硬件,选择一个多属性的父类,如CIM_LogicalDevice,下面将得到一个完整的硬件清单:
PS> Get-WmiObject -Class CIM_LogicalDevice Manufacturer Name Status StatusInfo ------------ ---- ------ ---------- Realtek Realtek High Def... OK 3 Kona OK Intel Corporation Intel(R) 8 Serie... OK Intel Corporation Intel(R) Wireles... Microsoft Microsoft Kernel... ASIX AX88772B US... Microsoft Virtueller Micro... Microsoft Bluetooth-Gerät ... Microsoft Microsoft-ISATAP... Microsoft-ISATAP... Microsoft Teredo Tunneling... Microsoft Von Microsoft ge... Microsoft-ISATAP... Microsoft-ISATAP... Microsoft-ISATAP... Microsoft-ISATAP... ASIX AX88772B US... Microsoft-ISATAP... Microsoft-ISATAP... Virtueller Micro... Microsoft-ISATAP... Microsoft-ISATAP... Microsoft-ISATAP... -Virtual Battery 0- CRB Battery 0 (...)
接着看看它们涉及的类,所以你现在可以更了解WMI中的硬件类了:
PS> Get-WmiObject -Class CIM_LogicalDevice | Group-Object -Property __Class -NoElement Count Name ----- ---- 1 Win32_SoundDevice 1 Win32_Battery 1 Win32_IDEController 20 Win32_NetworkAdapter 1 Win32_PortableBattery 10 Win32_Printer 1 Win32_Processor 2 Win32_DiskDrive 7 Win32_DiskPartition 1 Win32_Fan 2 Win32_Keyboard 5 Win32_LogicalDisk 2 Win32_MappedLogicalDisk 1 Win32_MemoryArray 2 Win32_MemoryDevice 2 Win32_PointingDevice 1 Win32_SCSIController 2 Win32_USBController 6 Win32_USBHub 5 Win32_Volume 4 Win32_CacheMemory 1 Win32_DesktopMonitor 1 Win32_VideoController 1 Win32_VoltageProbe 1 Win32_MotherboardDevice 8 Win32_Bus 134 Win32_PnPEntity
它基本上从 CIM_LogicalDevice 得到了全部的实例和将它们的类名分组。
本文链接: https://www.pstips.net/using-wmi-inheritance.html
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!