# How do I get the VALUE of a Property (in an object)??

**URL:** <https://forums.powershell.org/t/how-do-i-get-the-value-of-a-property-in-an-object/10786>\
**Category:** PowerShell Help\
**Created:** [June 8, 2018, 5:04am UTC](https://forums.powershell.org/t/how-do-i-get-the-value-of-a-property-in-an-object/10786 "2018-06-08T05:04:22Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rtan2010](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rtan2010/32/1173_2.png) [@rtan2010](https://forums.powershell.org/u/rtan2010)\
**Post date:** [June 8, 2018, 5:04am UTC](https://forums.powershell.org/t/how-do-i-get-the-value-of-a-property-in-an-object/10786/1 "2018-06-08T05:04:22Z")

</div>

I have the following chain of commands:

Get-WmiObject win32\_logicaldisk | Where-Object VolumeName -eq “DDRIVE” | Select-Object -property DeviceID

When executed, it produces 3 lines of output (actually 4, including the first line of blanks):

## DeviceID

D:

What cmdlet, function, or ??? can I use to extract just the value of the DeviceID property, which in this case is D: ?  
This is so I can assign it to a variable which will be concatenated to a specific folder to form a complete path name.  
Get-ItemPropertyValue can’t seem to do the job.  
Any advice, tips or pointers would be highly appreciated.

---

<div class="post-metadata">

**Author:** ![bakhtyar](https://avatars.discourse-cdn.com/v4/letter/b/da6949/32.png) [@bakhtyar](https://forums.powershell.org/u/bakhtyar)\
**Post date:** [June 8, 2018, 5:26am UTC](https://forums.powershell.org/t/how-do-i-get-the-value-of-a-property-in-an-object/10786/2 "2018-06-08T05:26:10Z")

</div>

```
Get-WmiObject win32_logicaldisk | Where-Object VolumeName -eq "DDRIVE" | % { write-output $_.DeviceID }
```

---

<div class="post-metadata">

**Author:** ![random-commandline](https://avatars.discourse-cdn.com/v4/letter/r/e56c9b/32.png) [@random-commandline](https://forums.powershell.org/u/random-commandline)\
**Post date:** [June 8, 2018, 5:37am UTC](https://forums.powershell.org/t/how-do-i-get-the-value-of-a-property-in-an-object/10786/3 "2018-06-08T05:37:30Z")

</div>

If I am not mistaken, all volume names are unique unless blank.

```
(Get-CimInstance -ClassName win32_logicaldisk -Filter "VolumeName='DDRIVE'").DeviceID
-OR-
(Get-WmiObject -Class win32_logicaldisk -Filter "VolumeName='DDRIVE'").DeviceID
```

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [June 8, 2018, 6:06am UTC](https://forums.powershell.org/t/how-do-i-get-the-value-of-a-property-in-an-object/10786/4 "2018-06-08T06:06:36Z")

</div>

… or the pure Powershell way …  
instead of

```
Select-Object -property DeviceID
```
 you do 
```
Select-Object -ExpandProperty DeviceID
```

---

<div class="post-metadata">

**Author:** ![rtan2010](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rtan2010/32/1173_2.png) [@rtan2010](https://forums.powershell.org/u/rtan2010)\
**Post date:** [June 8, 2018, 1:56pm UTC](https://forums.powershell.org/t/how-do-i-get-the-value-of-a-property-in-an-object/10786/5 "2018-06-08T13:56:06Z")

</div>

Many thanks, Mr/Ms Bakhtyar … your solution not only worked, but it made me realize why Get-ItemPropertyValue (which I was struggling to “make it work”) does not work.  
Best,

---

<div class="post-metadata">

**Author:** ![rtan2010](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rtan2010/32/1173_2.png) [@rtan2010](https://forums.powershell.org/u/rtan2010)\
**Post date:** [June 8, 2018, 2:01pm UTC](https://forums.powershell.org/t/how-do-i-get-the-value-of-a-property-in-an-object/10786/6 "2018-06-08T14:01:44Z")

</div>

Yes, you are right. Many thanks for giving 2 ways of doing the same thing.  
While I do not yet know the finer differences between WmiObject and CmiInstance, I hope to read about them in order to appreciate which one is more appropriate under certain specific conditions, and other finer aspects as efficiency, etc…  
My sincerest thanks for your technical tip, it has enhanced my learning process.

---

<div class="post-metadata">

**Author:** ![rtan2010](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rtan2010/32/1173_2.png) [@rtan2010](https://forums.powershell.org/u/rtan2010)\
**Post date:** [June 8, 2018, 2:36pm UTC](https://forums.powershell.org/t/how-do-i-get-the-value-of-a-property-in-an-object/10786/7 "2018-06-08T14:36:24Z")

</div>

Thank you! It works perfectly. The documentation on the -ExpandProperty parameter is limited, so I do not claim to understand what it is really doing behind the scenes. All I know is that in the object-oriented world of Poweershell (which is great!) there are other “new properties” - e.g., AliasProperty,NoteProperty - that have been added to the original Property concept in object-oriented approaches. Would be grateful if you can point me to references/sites/docs that explain the -ExpandProperty in more detail. Thanks again.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:34pm UTC](https://forums.powershell.org/t/how-do-i-get-the-value-of-a-property-in-an-object/10786/8 "2024-05-16T20:34:57Z")

</div>

Closed on May 16, 2024, 8:34pm UTC


