In Win32_DiskDrive. There’s a Capabilities Property which has a type of System.UInt16[].
Am trying to get the values by using GetProperty and convert it to string. But it keeps throwing an error (I don’t want to trap it) on Capabilities property.
The error was: InvalidCastException
Message: Object must implement IConvertible.
There’s the WMI Code Creator tool from Microsoft that can generate C#, Visual Basic .NET and VBScript code for you to run any WMI query and enumerate the results. It’s also very useful for exploring WMI namespaces and classes, so it’s a must-have when dealing with WMI.
Now back to the question. From the
System.UInt16[]syntax I assume that you’re using C#. Here’s sample C# code (generated by WMI Code Creator, with a few minor changes) that demonstrates how you can access individual elements of theCapabilitiesarray:To convert a
UInt16value to a string, you can use theToStringmethod, for example: