使用WMI和WMQ从SERVICE类型USBSTOR的Win32_PnPEntity获取逻辑磁盘和分区信息
我正在检测我们的专有 USB 设备何时连接到 PC。当我们检测到这一点时,我们会得到相关的 Win32_PnPEntity。我们希望使用此 Win32_PnPEntity 作为以下信息的来源:
- USB 描述符 VID、PID、REV、固件版本。
- 逻辑磁盘驱动器卷和分区信息以获取驱动器号信息。
我遇到的问题是试图弄清楚如何使用 WMI 和 WMQ 从 Win32_PnPEntity 获取逻辑磁盘和分区信息。 Win32_PnPEntity 属于服务类型USBSTOR(我认为是USB存储?)
以下是我当前经历的过程的描述:
我听Win32_USBControllerDevice 与事件观察器,以便检测 USB 设备何时与 PC 连接或分离。我使用以下查询来限制事件发生的情况:
“从
中选择* __InstanceOperationEvent 在 1 内,其中 TargetInstance ISA
“Win32_USBControllerDevice”和
TargetInstance.__RELPATH LIKE '%DeviceId=%VID_1111%'"
当此事件发生时,我会提取“Win32_USBControllerDevice.Dependent”属性并提取“DeviceId”值。然后,我将这个“DeviceId”值与 Win32_PNPEntity 类一起使用来获取关联的实例,
这对我来说是一件棘手的事情......
我需要访问 <与Win32_PnPEntity实例相关的strong>Win32_DiskDrive我需要这个实例来获取卷信息,这样我就可以获得每个分区分配的驱动器号,但我没有。 我经历
了这个过程,因为 Win32_PnPEntity 提供了用于限制事件侦听和搜索的 VID、PID...但它也提供了我需要的固件版本。从现在起,我想获取 Win32_PnPEntity 的 Win32_DiskDrive
任何输入将不胜感激
--- 更好地描述问题的额外信息:
我已经采取的步骤。目前为止情况如下:
- 监听“Win32_USBControllerDevice”的“__InstanceModificaitionEvent”
- 从“__InstanceModificaitionEvent”的“TargetInstnace”获取“Win32_PnPEntity”
- 从“Win32_PnPEntity”获取“DeviceId”,其中包含 PID、VID 信息。
我现在遇到的问题是试图找到“Win32_LogicalDisk”和/或“Win32_DiskDrive”和/或“Win32_DiskPartition”或一些其他关联器或引用链接到已为“大容量存储”实例分配的 USB 设备所连接的驱动器号。
我能想到的最好的方法是在下面的“图表”中描述:
USB DEVICE
| |
----------| |----
| Win32_DiskDrive | Win32_PnPEntity
我想做的是弄清楚如何从 USB 设备的“Win32_PnPEntity”表示形式获取“Win32_DiskDrive”表示形式。
以下是我在连接设备时运行的 powershell 脚本。它为我提供了属于 USB 设备的所有实例。我知道它们属于一个设备,因为我只连接了其中一个设备,并且通过我们对 USB 描述符的自定义编辑,我知道会发生什么。
PS C:\Users\USER.DOMAIN> gwmi Win32_PNPEntity |? { ($_.DeviceId -match 'VEN_MYCOMPANY&') - 或 ($_.DeviceId -match 'VID_XXXX')}
__GENUS : 2
__CLASS:Win32_PnPEntity
__SUPERCLASS:CIM_LogicalDevice
__王朝:CIM_ManagedSystemElement
__RELPATH : Win32_PnPEntity.DeviceID="USB\VID_XXXX&PID_0001\YYYY"
__PROPERTY_COUNT:24
__派生:{CIM_LogicalDevice、CIM_LogicalElement、CIM_ManagedSystemElement}
__服务器:默认
__命名空间:根\cimv2
__PATH : \BYDEFAULT\root\cimv2:Win32_PnPEntity.DeviceID="USB\VID_XXXX&PID_0001\YYYY"
可用性:
标题:USB 大容量存储设备
类Guid:{36fc9e60-c465-11cf-8056-444553540000}
兼容ID:{USB\Class_08&SubClass_06&Prot_50、USB\Class_08&SubClass_06、USB\Class_08}
配置管理器错误代码:0
ConfigManagerUserConfig:假
创建类名称:Win32_PnPEntity
描述 : USB 大容量存储设备
设备ID:USB\VID_XXXX&PID_0001\YYYY
错误已清除:
错误描述:
硬件ID:{USB\VID_XXXX&PID_0001&REV_0001,USB\VID_XXXX&PID_0001}
安装日期:
最后错误代码:
制造商 : 兼容 USB 存储设备
名称 : USB 大容量存储设备
PNPDeviceID : USB\VID_XXXX&PID_0001\YYYY
电源管理功能:
电源管理支持:
服务:USBSTOR
状态:正常
状态信息:
系统创建类名称:Win32_ComputerSystem
系统名称:默认
__GENUS:2
__CLASS:Win32_PnPEntity
__SUPERCLASS:CIM_LogicalDevice
__王朝:CIM_ManagedSystemElement
__RELPATH : Win32_PnPEntity.DeviceID="WPDBUSENUMROOT\UMB\2&37C186B&0&STORAGE#VOLUME#_??_USBSTOR#DISK&VEN_MYCOMPANY&PROD_ZZZZ_-_STORAGE&REV_5678#YYYY&0#"
__PROPERTY_COUNT:24
__派生:{CIM_LogicalDevice、CIM_LogicalElement、CIM_ManagedSystemElement}
__服务器:默认
__命名空间:根\cimv2
__PATH : \BYDEFAULT\root\cimv2:Win32_PnPEntity.DeviceID="WPDBUSENUMROOT\UMB\2&37C186B&0&STORAGE#VOLUME#_??_USBSTOR#DISK&VEN_MYCOMPANYI&PROD_ZZZZ_-_STORAGE&REV_5678#YYYY&0 #”
可用性:
标题:ZZZZ
类Guid:{eec5ad98-8080-425f-922a-dabf3de3f69a}
兼容ID:{wpdbusenum\fs}
配置管理器错误代码:10
ConfigManagerUserConfig:假
创建类名称:Win32_PnPEntity
描述:我的公司 - 存储
设备 ID : WPDBUSENUMROOT\UMB\2&37C186B&0&STORAGE#VOLUME#_??_USBSTOR#DISK&VEN_MYCOMPANY&PROD_ZZZZ_-_STORAGE&REV_5678#YYYY&0#
错误已清除:
错误描述:
硬件ID:
安装日期:
最后错误代码:
制造商:MYCOMPANY
姓名:ZZZZ
PNPDeviceID : WPDBUSENUMROOT\UMB\2&37C186B&0&STORAGE#VOLUME#_??_USBSTOR#DISK&VEN_MYCOMPANY&PROD_ZZZZ_-_STORAGE&REV_5678#YYYY&0#
电源管理功能:
电源管理支持:
服务:WUDFRd
状态:错误
状态信息:
系统创建类名称:Win32_ComputerSystem
系统名称:默认
__GENUS:2
__CLASS:Win32_PnPEntity
__SUPERCLASS:CIM_LogicalDevice
__王朝:CIM_ManagedSystemElement
__RELPATH : Win32_PnPEntity.DeviceID="STORAGE\VOLUME\_??_USBSTOR#DISK&VEN_MYCOMPANY&PROD_ZZZZ_-_STORAGE&REV_5678#YYYY&0#{53F56307-B6BF-11D0-94F2-00A0C91EFB8B}"
__PROPERTY_COUNT:24
__派生:{CIM_LogicalDevice、CIM_LogicalElement、CIM_ManagedSystemElement}
__服务器:默认
__命名空间:根\cimv2
__PATH : \BYDEFAULT\root\cimv2:Win32_PnPEntity.DeviceID="STORAGE\VOLUME\_??_USBSTOR#DISK&VEN_MYCOMPANY&PROD_ZZZZ_-_STORAGE&REV_5678#YYYY&0#{53F56307-B6BF-11D0-94F2-00A 0C91EFB8B}"< br> 可用性:
标题:通用卷
类Guid:{71a27cdd-812a-11d0-bec7-08002be2092f}
兼容ID:
配置管理器错误代码:0
ConfigManagerUserConfig:假
创建类名称:Win32_PnPEntity
描述:通用卷
设备ID:存储\卷_??_USBSTOR#DISK&VEN_MYCOMPANY&PROD_ZZZZ_-_STORAGE&REV_5678#YYYY&0#{53F56307-B6BF-11D0-94F2-00A0C91EFB8B}
错误已清除:
错误描述:
硬件ID:{存储\卷}
安装日期:
最后错误代码:
制造商:微软
名称 : 通用卷
PNPDeviceID : 存储\VOLUME_??_USBSTOR#DISK&VEN_MYCOMPANY&PROD_ZZZZ_-_STORAGE&REV_5678#YYYY&0#{53F56307-B6BF-11D0-94F2-00A0C91EFB8B}
电源管理功能:
电源管理支持:
服务:volsnap
状态:正常
状态信息:
系统创建类名称:Win32_ComputerSystem
系统名称:默认
属:2
__CLASS:Win32_PnPEntity
__SUPERCLASS:CIM_LogicalDevice
__王朝:CIM_ManagedSystemElement
__RELPATH : Win32_PnPEntity.DeviceID="USBSTOR\DISK&VEN_MYCOMPANY&PROD_ZZZZ_-_STORAGE&REV_5678\YYYY&0"
__PROPERTY_COUNT:24
__派生:{CIM_LogicalDevice、CIM_LogicalElement、CIM_ManagedSystemElement}
__服务器:默认
__命名空间:根\cimv2
__PATH : \BYDEFAULT\root\cimv2:Win32_PnPEntity.DeviceID="USBSTOR\DISK&VEN_MYCOMPANY&PROD_ZZZZ_-_STORAGE&REV_5678\YYYY&0"
可用性:
说明文字 : MYCOMPANY ZZZZ - 存储 USB 设备
类Guid:{4d36e967-e325-11ce-bfc1-08002be10318}
兼容ID:{USBSTOR\磁盘、USBSTOR\RAW}
配置管理器错误代码:0
ConfigManagerUserConfig:假
创建类名称:Win32_PnPEntity
描述:磁盘驱动器
设备ID:USBSTOR\DISK&VEN_MYCOMPANY&PROD_ZZZZ_-_STORAGE&REV_5678\YYYY&0
错误已清除:
错误描述:
硬件ID:{USBSTOR\DiskMYCOMPANY___ZZZZ___Storage5678、USBSTOR\DiskMYCOMPANY___ZZZZ_-存储、USBSTOR\DiskMYCOMPANY、USBSTOR\MYCOMPANY___ZZZZ__-_Storage5...}
安装日期:
最后错误代码:
制造商:(标准磁盘驱动器)
名称:MYCOMPANY ZZZZ - 存储 USB 设备
PNPDeviceID : USBSTOR\DISK&VEN_MYCOMPANY&PROD_ZZZZ_-_STORAGE&REV_5678\YYYY&0
电源管理功能:
电源管理支持:
服务:磁盘
状态:正常
状态信息:
系统创建类名称:Win32_ComputerSystem
SystemName : BYDEFAULT
上面的结果集显示了很多信息。
结果 1 -“服务类型”为“USBSTOR”。这是我在侦听“__InstanceModificaitionEvent”时想要使用的 Win32_PnPEntity,因为它为我提供了 VID 和 PID。
结果 2 - 是我不感兴趣的复合设备表示。
结果 3 -“服务类型”为“volsnap”。这是体积实体,我对此感兴趣。
结果 4 -“服务类型”是“磁盘”。这是磁盘实体,我对此很感兴趣。
如何获取“结果 1”和“结果 3”和/或“结果 4”之间的关系?
我尝试过使用“Win32_PnPDevice”关联类,但它似乎没有让我达到我需要的程度。我是这个 powershell WMI 和 WMQ 环境的新手,因此我很可能没有正确使用“Win32_PnPDevice”。
我运行了以下查询来识别相关“Win32_PnPDevice”实体的“SameElement”和“SystemElement”属性上的内容:
gwmi Win32_PNPDevice |%{[wmi]
(
$.SameElement)
} |选择 {$.Name、$.Description、$.DeviceId、$_.Status}
gwmi Win32_PNPDevice |%{[wmi](
$.SystemElement)
} |选择 {$.Name、$.Description、$.DeviceId、$_.Status}
读取结果如下:
Win32_PNPDevice.SameElement - {PHYSICALDRIVE1,磁盘驱动器, 物理驱动器1,好的} Win32_PNPDevice.SystemElement - {MYCOMPANY ZZZZ - 存储 USB 设备, 磁盘驱动器, USBSTOR_DISK&VEN_MYCOMPANY&PROD_ZZZZ_-_STORAGE&REV_5678_YYYY&0, 好的}
Win32_PNPDevice.SameElement - {USB 大容量存储设备,USB 大容量存储 设备,USB_VID_XXXX&PID_0001_YYYY, 好的}
Win32_PNPDevice.SystemElement - {USB 大容量存储设备、USB 大容量 存储设备, USB_VID_XXXX&PID_0001_YYYY,确定}
也许我错误地使用了“Win32_PnPDevice”类,但似乎我无法将“Win32_PnPEntity”连接到“Win32_DiskDrive”...
我希望这些额外信息能更好地描述我的问题。
I am detecting when our proprietary USB device is attached to a PC. When we detect this, we get the related Win32_PnPEntity. We want to use this Win32_PnPEntity as a source of the following information:
- USB Descriptor VID, PID, REV, Firmware Version.
- Logical Disk Drive Volume and Partition information to get Drive Letter information.
The problem I am having is trying to figure out how to use WMI and WMQ to get to the Logical Disk and partition information from the Win32_PnPEntity.
The Win32_PnPEntity is of Service type USBSTOR (USB Storage I think?)
Following is a description of the process I currently go through:
I listen to the Win32_USBControllerDevice with the event watcher so as to detect when the USB Device is attached or detached from the PC. I use the following query to constrain what comes through on the event:
"SELECT * FROM
__InstanceOperationEvent WITHIN 1 WHERE TargetInstance ISA
'Win32_USBControllerDevice' AND
TargetInstance.__RELPATH LIKE '%DeviceId=%VID_1111%'"
When this event comes through I pull the "Win32_USBControllerDevice.Dependent" property and pull out the "DeviceId" value. I then use this "DeviceId" value with the Win32_PNPEntity class to get the associated instance.
This is where things get tricky for me...
I need to get to the Win32_DiskDrive that the Win32_PnPEntity instance relates to. I need this instance so as to get to the volume information, so I can get the drive letter each partition is assigned. But I have no idea on how to get to it.
I go through this process as the Win32_PnPEntity provides the VID, PID for constraint on event listening and searching... but it also provides the Firmware Version which I need. So from this point I want to get the Win32_DiskDrive for the Win32_PnPEntity.
Any input would be appreciated.
--- EXTRA INFORMATION TO BETTER DESCRIBE THE ISSUE:
The steps I have got working so far are as follows:
- Listen to the '__InstanceModificaitionEvent' for the 'Win32_USBControllerDevice'
- Get the 'Win32_PnPEntity' from the 'TargetInstnace' of the '__InstanceModificaitionEvent'
- Get the 'DeviceId' from the 'Win32_PnPEntity' which contains the PID, VID information.
The issue I have now is trying to find the 'Win32_LogicalDisk' AND/OR 'Win32_DiskDrive' AND/OR 'Win32_DiskPartition' OR some other ASSOCIATOR or REFERENCES link to the drive letter the USB device attached has been assigned for the 'Mass Storge' instance.
The best way I can think of the issue is described in the following 'diagram':
USB DEVICE
| |
----------| |----
| Win32_DiskDrive | Win32_PnPEntity
What I am trying to do, is figure out how to get from the 'Win32_PnPEntity' representation of the USB Device to the 'Win32_DiskDrive' representation.
Following is a powershell script I run, while the device is attached. It gives me all the instances that belong to the USB Device. I know they belong to the one device as I have attached only one of the devices and with our custom editing of the USB DESCRIPTOR I know what to expect.
PS C:\Users\USER.DOMAIN> gwmi Win32_PNPEntity |? { ($_.DeviceId -match 'VEN_MYCOMPANY&') -or ($_.DeviceId -match 'VID_XXXX')}
__GENUS : 2
__CLASS : Win32_PnPEntity
__SUPERCLASS : CIM_LogicalDevice
__DYNASTY : CIM_ManagedSystemElement
__RELPATH : Win32_PnPEntity.DeviceID="USB\VID_XXXX&PID_0001\YYYY"
__PROPERTY_COUNT : 24
__DERIVATION : {CIM_LogicalDevice, CIM_LogicalElement, CIM_ManagedSystemElement}
__SERVER : BYDEFAULT
__NAMESPACE : root\cimv2
__PATH : \BYDEFAULT\root\cimv2:Win32_PnPEntity.DeviceID="USB\VID_XXXX&PID_0001\YYYY"
Availability :
Caption : USB Mass Storage Device
ClassGuid : {36fc9e60-c465-11cf-8056-444553540000}
CompatibleID : {USB\Class_08&SubClass_06&Prot_50, USB\Class_08&SubClass_06, USB\Class_08}
ConfigManagerErrorCode : 0
ConfigManagerUserConfig : False
CreationClassName : Win32_PnPEntity
Description : USB Mass Storage Device
DeviceID : USB\VID_XXXX&PID_0001\YYYY
ErrorCleared :
ErrorDescription :
HardwareID : {USB\VID_XXXX&PID_0001&REV_0001, USB\VID_XXXX&PID_0001}
InstallDate :
LastErrorCode :
Manufacturer : Compatible USB storage device
Name : USB Mass Storage Device
PNPDeviceID : USB\VID_XXXX&PID_0001\YYYY
PowerManagementCapabilities :
PowerManagementSupported :
Service : USBSTOR
Status : OK
StatusInfo :
SystemCreationClassName : Win32_ComputerSystem
SystemName : BYDEFAULT
__GENUS : 2
__CLASS : Win32_PnPEntity
__SUPERCLASS : CIM_LogicalDevice
__DYNASTY : CIM_ManagedSystemElement
__RELPATH : Win32_PnPEntity.DeviceID="WPDBUSENUMROOT\UMB\2&37C186B&0&STORAGE#VOLUME#_??_USBSTOR#DISK&VEN_MYCOMPANY&PROD_ZZZZ_-_STORAGE&REV_5678#YYYY&0#"
__PROPERTY_COUNT : 24
__DERIVATION : {CIM_LogicalDevice, CIM_LogicalElement, CIM_ManagedSystemElement}
__SERVER : BYDEFAULT
__NAMESPACE : root\cimv2
__PATH : \BYDEFAULT\root\cimv2:Win32_PnPEntity.DeviceID="WPDBUSENUMROOT\UMB\2&37C186B&0&STORAGE#VOLUME#_??_USBSTOR#DISK&VEN_MYCOMPANYI&PROD_ZZZZ_-_STORAGE&REV_5678#YYYY&0#"
Availability :
Caption : ZZZZ
ClassGuid : {eec5ad98-8080-425f-922a-dabf3de3f69a}
CompatibleID : {wpdbusenum\fs}
ConfigManagerErrorCode : 10
ConfigManagerUserConfig : False
CreationClassName : Win32_PnPEntity
Description : MYCOMPANY - Storage
DeviceID : WPDBUSENUMROOT\UMB\2&37C186B&0&STORAGE#VOLUME#_??_USBSTOR#DISK&VEN_MYCOMPANY&PROD_ZZZZ_-_STORAGE&REV_5678#YYYY&0#
ErrorCleared :
ErrorDescription :
HardwareID :
InstallDate :
LastErrorCode :
Manufacturer : MYCOMPANY
Name : ZZZZ
PNPDeviceID : WPDBUSENUMROOT\UMB\2&37C186B&0&STORAGE#VOLUME#_??_USBSTOR#DISK&VEN_MYCOMPANY&PROD_ZZZZ_-_STORAGE&REV_5678#YYYY&0#
PowerManagementCapabilities :
PowerManagementSupported :
Service : WUDFRd
Status : Error
StatusInfo :
SystemCreationClassName : Win32_ComputerSystem
SystemName : BYDEFAULT
__GENUS : 2
__CLASS : Win32_PnPEntity
__SUPERCLASS : CIM_LogicalDevice
__DYNASTY : CIM_ManagedSystemElement
__RELPATH : Win32_PnPEntity.DeviceID="STORAGE\VOLUME\_??_USBSTOR#DISK&VEN_MYCOMPANY&PROD_ZZZZ_-_STORAGE&REV_5678#YYYY&0#{53F56307-B6BF-11D0-94F2-00A0C91EFB8B}"
__PROPERTY_COUNT : 24
__DERIVATION : {CIM_LogicalDevice, CIM_LogicalElement, CIM_ManagedSystemElement}
__SERVER : BYDEFAULT
__NAMESPACE : root\cimv2
__PATH : \BYDEFAULT\root\cimv2:Win32_PnPEntity.DeviceID="STORAGE\VOLUME\_??_USBSTOR#DISK&VEN_MYCOMPANY&PROD_ZZZZ_-_STORAGE&REV_5678#YYYY&0#{53F56307-B6BF-11D0-94F2-00A0C91EFB8B}"
Availability :
Caption : Generic volume
ClassGuid : {71a27cdd-812a-11d0-bec7-08002be2092f}
CompatibleID :
ConfigManagerErrorCode : 0
ConfigManagerUserConfig : False
CreationClassName : Win32_PnPEntity
Description : Generic volume
DeviceID : STORAGE\VOLUME_??_USBSTOR#DISK&VEN_MYCOMPANY&PROD_ZZZZ_-_STORAGE&REV_5678#YYYY&0#{53F56307-B6BF-11D0-94F2-00A0C91EFB8B}
ErrorCleared :
ErrorDescription :
HardwareID : {STORAGE\Volume}
InstallDate :
LastErrorCode :
Manufacturer : Microsoft
Name : Generic volume
PNPDeviceID : STORAGE\VOLUME_??_USBSTOR#DISK&VEN_MYCOMPANY&PROD_ZZZZ_-_STORAGE&REV_5678#YYYY&0#{53F56307-B6BF-11D0-94F2-00A0C91EFB8B}
PowerManagementCapabilities :
PowerManagementSupported :
Service : volsnap
Status : OK
StatusInfo :
SystemCreationClassName : Win32_ComputerSystem
SystemName : BYDEFAULT
GENUS : 2
__CLASS : Win32_PnPEntity
__SUPERCLASS : CIM_LogicalDevice
__DYNASTY : CIM_ManagedSystemElement
__RELPATH : Win32_PnPEntity.DeviceID="USBSTOR\DISK&VEN_MYCOMPANY&PROD_ZZZZ_-_STORAGE&REV_5678\YYYY&0"
__PROPERTY_COUNT : 24
__DERIVATION : {CIM_LogicalDevice, CIM_LogicalElement, CIM_ManagedSystemElement}
__SERVER : BYDEFAULT
__NAMESPACE : root\cimv2
__PATH : \BYDEFAULT\root\cimv2:Win32_PnPEntity.DeviceID="USBSTOR\DISK&VEN_MYCOMPANY&PROD_ZZZZ_-_STORAGE&REV_5678\YYYY&0"
Availability :
Caption : MYCOMPANY ZZZZ - Storage USB Device
ClassGuid : {4d36e967-e325-11ce-bfc1-08002be10318}
CompatibleID : {USBSTOR\Disk, USBSTOR\RAW}
ConfigManagerErrorCode : 0
ConfigManagerUserConfig : False
CreationClassName : Win32_PnPEntity
Description : Disk drive
DeviceID : USBSTOR\DISK&VEN_MYCOMPANY&PROD_ZZZZ_-_STORAGE&REV_5678\YYYY&0
ErrorCleared :
ErrorDescription :
HardwareID : {USBSTOR\DiskMYCOMPANY___ZZZZ_-_Storage5678, USBSTOR\DiskMYCOMPANY___ZZZZ_-Storage, USBSTOR\DiskMYCOMPANY, USBSTOR\MYCOMPANY___ZZZZ_-_Storage5...}
InstallDate :
LastErrorCode :
Manufacturer : (Standard disk drives)
Name : MYCOMPANY ZZZZ - Storage USB Device
PNPDeviceID : USBSTOR\DISK&VEN_MYCOMPANY&PROD_ZZZZ_-_STORAGE&REV_5678\YYYY&0
PowerManagementCapabilities :
PowerManagementSupported :
Service : disk
Status : OK
StatusInfo :
SystemCreationClassName : Win32_ComputerSystem
SystemName : BYDEFAULT
The above result set shows a lot of information.
Result 1 - 'SERVICE TYPE' is 'USBSTOR'. This is the Win32_PnPEntity I want to use when listening to '__InstanceModificaitionEvent' as it gives me the VID and PID.
Result 2 - Is the Composite Device representation which I am not interested in.
Result 3 - 'SERVICE TYPE' is 'volsnap'. This is the volume entity and I am interested in this.
Result 4 - 'SERVICE TYPE' is 'disk'. This is the disk entity and I am interested in this.
How do I get the relationship between 'Result 1' and 'Result 3' AND/OR 'Result 4'?
I have tried using the 'Win32_PnPDevice' associating class but it does not seem to get me to the point I need. I am new to this powershell WMI and WMQ environment and so it is quite possible I am not using the 'Win32_PnPDevice' correctly.
I ran the following query to identify what was on the' SameElement' and 'SystemElement' properties of the relevant 'Win32_PnPDevice' entity:
gwmi Win32_PNPDevice |%{[wmi]
(
$.SameElement)
} | select {$.Name, $.Description, $.DeviceId, $_.Status}
gwmi Win32_PNPDevice |%{[wmi](
$.SystemElement)
} | select {$.Name, $.Description, $.DeviceId, $_.Status}
The results can be read as follows:
Win32_PNPDevice.SameElement - {PHYSICALDRIVE1, Disk drive,
PHYSICALDRIVE1, OK}
Win32_PNPDevice.SystemElement - {MYCOMPANY ZZZZ - Storage USB Device,
Disk drive,
USBSTOR_DISK&VEN_MYCOMPANY&PROD_ZZZZ_-_STORAGE&REV_5678_YYYY&0,
OK}Win32_PNPDevice.SameElement - {USB Mass Storage Device, USB Mass Storage
Device, USB_VID_XXXX&PID_0001_YYYY,
OK}
Win32_PNPDevice.SystemElement - {USB Mass Storage Device, USB Mass
Storage Device,
USB_VID_XXXX&PID_0001_YYYY, OK}
Maybe I am using the 'Win32_PnPDevice' class incorrectly but it would seem that I can not connect the 'Win32_PnPEntity' to the 'Win32_DiskDrive'...
I hope this extra information better describes my issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论