I've gone through few posts and articles that discuss how to use powershell access usb drive like:
- Browse files on camera using PowerShell
- List all devices, partitions and volumes in Powershell
- https://superuser.com/a/377008/9546
But none of them actually "answers" the question. The last post shared also says no one has ever created an MTP solution because of certain limitations that MTP (protocol) itself has.
One route I've taken kind of hit a wall; I don't know what to do next (with the wmi object). I've used the following vbscript program, and made note of the device id of the device I am interested in obtained from here:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colDevices = objWMIService.ExecQuery _
("Select * From Win32_USBControllerDevice")
For Each objDevice in colDevices
strDeviceName = objDevice.Dependent
strQuotes = Chr(34)
strDeviceName = Replace(strDeviceName, strQuotes, "")
arrDeviceNames = Split(strDeviceName, "=")
strDeviceName = arrDeviceNames(1)
Set colUSBDevices = objWMIService.ExecQuery _
("Select * From Win32_PnPEntity Where DeviceID = '" & strDeviceName & "'")
For Each objUSBDevice in colUSBDevices
Wscript.Echo objUSBDevice.Description
Next
Next
I've kind of plugged that in the below powershell command to get the wmi object:
Get-WmiObject win32_pnpentity -filter "DeviceID='<the_device_id>'"
Now I think I have the WMI object. But what can I do with it.
Coming from the last post I've linked to I have a hunch there is a COM way to deal with this. How do we have to do that?