title: How to get list of drive letters in Powershell 2.0
body: <p>I'm trying to get a list of drive letters in a drop-down menu. I'm currently using the code below and it works just fine in Windows 10, but doesn't work at all in Windows 7.</p>
  
  <pre><code>     $Drive_Letters = Get-WmiObject Win32_LogicalDisk
       ForEach ($Drives in $Drive_Letters.DeviceID) { $Dest_Drive_Box.Items.Add($Drives) }
  </code></pre>
  
  <p>In Win 7 I tried adjusting the code to this...</p>
  
  <pre><code>     $Drive_Letters = Get-WmiObject Win32_LogicalDisk | Select-Object DeviceID
       ForEach ($Drives in $Drive_Letters) { $Dest_Drive_Box.Items.Add($Drives) }
  </code></pre>
  
  <p>But now it shows "@DeviceID=C:}", "@DeviceID=D:}", etc. in Win 7 and 10 for each drive letter. I need to just show "C:", "D:", etc.</p>
  
  <p>Thanks!</p>