title: Powershell and wmi, how to map logical disk/volumes to a hard disk or vice versa?
body: <pre><code>Get-WmiObject -ComputerName $ip -Credential $credential -Class Win32_logicaldisk
  </code></pre>
  
  <p>This gets me disks as I see them in "My computer", eg. C:, D:, E:
  Now how I get corresponding underlying physical disks ? </p>
  
  <p>If I run following command </p>
  
  <pre><code>Get-WmiObject -ComputerName $ip -Credential $credential -Class win32_diskdrive
  </code></pre>
  
  <p>I get disk 0, disk 1, disk 2</p>
  
  <p>So how to find out which logical disk is on which physical disk ?</p>
  
  <p>Another question is how to find out volume number ? If I run diskpart and executes "list volume" I get the following output</p>
  
  <pre><code>  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
    ----------  ---  -----------  -----  ----------  -------  ---------  --------
    Volume 2     C                NTFS   Partition     59 GB  Healthy    Boot
    ...
  </code></pre>
  
  <p>How can I find out that logical disk C: is Volume 2 ?</p>
  
  <p>best regards, Primoz.</p>