Reputation: 1116
PS C:\script> $a
Caption DeviceID Model Partitions Size
Intel Raid 1 Volume \\.\PHYSICALDRIVE0 Intel Raid 1 Volume 2 456116451840
Intel Raid 1 Volume \\.\PHYSICALDRIVE1 Intel Raid 1 Volume 1 1900409817600
How can I only list the DeviceID column? Desired output:
\\.\PHYSICALDRIVE0
\\.\PHYSICALDRIVE1
Upvotes: 1
Views: 2479
Reputation: 2457
Assuming that $a
is a valid PSObject, you can achieve this using either the -Property
parameter or -ExpandProperty
parameter of Select-Object
cmdlet.
The difference being, using -Property
parameter means that you're just specifying a Property to select. That's it. But if you're using -ExpandProperty
parameter, you'll be specifying a property to select as well as prompting PowerShell to make an attempt to expand that property (in case the property itself is an Array or an Object).
Since in your use case, the property DeviceId is a normal NoteProperty, you can simply use something like this:
$a | Select-Object -Property DeviceId
Upvotes: 2