Using the WPD API
The WPD API is a COM API. Unfortunately it does not support IDispatch so we can't use it in scripting. You could use it in .Net with some interop magic, but that's an extended exercise :).
We'll write samples in C++ to illustrate using the API and as we are going along, we'll try addressing the scripting limitation by building a thin automation COM wrapper around the WPD API.
You'll need to include PortableDeviceApi.h and PortableDevice.h and link against PortableDeviceGUIDs.lib for most of the snippets here. I'll try calling out additional headers whenever required.