I have the following PowerShell command which returns all sorts of properties about disk drives attached to the system:
Get-WmiObject -Class Win32_Volume | Where-Object {$_.DeviceID -like "\\?\*"}
I'm only interested in the DriveLetter
and DeviceID
properties and would like them to be returned in a table something like this:
DriveLetter DeviceID
C: \\?\Volume{5b982fce-d9e5-11e1-9c28-806e6f6e6963}\
D: \\?\Volume{e9820c98-d688-11e1-a45f-001e673f1fc5}\
I know that I can surround my original command and use the dot operator to return one of my properties at a time:
(Get-WmiObject -Class Win32_Volume | Where-Object {$_.DeviceID -like "\\?\*"}).DriveLetter
Which in return produces:
C:
D:
But I don't know how to write a single statement that will return two (or more) properties as a table. If it's not possible to accomplish this with a single statement, what am I to do in order to produce the desired table output?
I have searched Google for an answer but because I'm pretty new to PowerShell I probably am not phrasing my search terms correctly and thus not getting what I imagine is the simple answer to my question.