Matching Windows disk to VM disk in VMWare

UPDATE 2018-02-12: The script below has some issues. I found better version here:https://communities.vmware.com/thread/548671

Those who have experience in VMWare know that there is no 1 to 1 match between VM’s disk number and the disk inside guest OS.

You can use this script to export disk mappings to grid or to a csv file:https://github.com/PKGeorgiev/PowerShell-VMWare/blob/master/Get-VmDiskToWindowsDiskMapping.ps1

This script is a slight modification of Conrad’s version with some improvements:

  1. Allow pipelining
  2. Use Guest’s hostname in all WMI calls instead of VM’s name (they can differ)
  3. Formatting and error checking

Examples:

Notes:

  1. This script requires PowerCli
  2. You must have the rights to connect to Guest OS via WMI (i.e. be an administrator or by custom rights on WMI service)
  3. The script allows pipelining
  4. In case of exception the Error field will contain the reason/message. All other fields will stay empty.
  5. The script does not show MountPoints because there is no easy way to do it via WMI (even impossible). There are some ways but they require PowerShell Remoting or PSExec which is not always possible.

References:

Leave a Reply

Your email address will not be published. Required fields are marked *

*