SBTools module, adds function to get VM’s VHD file path


You may need to track the location of Hyper-V virtual machines’ VHD files. This may be important to identify the storage platform where a particular VM drive is located, which is in turn important in troubleshooting performance and disk IO issues.

To use this function, download SBTools.rar from the Microsoft Script Center Repository and run .\install-SBTools.ps1

The difficulty in identifying where a VM drive resides physically lies in the fact that VM drives are referred to differently from the VM and its host’s prospectives. This module includes a function; Get-SBVHD that retrieves a VM’s drive VHD file path. For example, consider this VM:

SBTools01

It has a total of 7 disks: 3 attached to 2 different IDE controllers, and 4 attached to 2 different SCSI controllers.

From the Hyper-V host’s prospective the 7 disks look like:

From the host’s prospective
ControllerType ControllerNumber ControllerLocation
ide 0 0
ide 0 1
ide 1 1
scsi 0 0
scsi 0 1
scsi 0 2
scsi 1 0

However, from the guest virtual machine’s prospective the 7 disks are identified as:

From the Guest’s prospective
Controller DiskNumber
ide 0
ide 1
ide 2
scsi 3
scsi 4
scsi 5
scsi 6

The host can tell us the VHD path to the VM disk presented in SCSI controller 0 location 1 for example, but it’s unaware of what’s on the disk in terms of partitions, and volumes.

The guest can tell us the volumes on a particular partition and the partitions on a particular disk, but it’s unaware of the VHD file path that represents this disk.

To add another wrinkle, starting with a guest VM’s drive letter, a volume has no information on what partition it resides on. Also, a partition has no information on what disk it resides on.

For example:

(get-volume -DriveLetter d) | Select-Object *

returns output similar to:

HealthStatus : Healthy
DriveType : Fixed
DriveLetter : D
FileSystem : NTFS
FileSystemLabel :
ObjectId : \\?\Volume{6e7e57fb-e9c7-11e3-80bd-00155d65010c}\
Path : \\?\Volume{6e7e57fb-e9c7-11e3-80bd-00155d65010c}\
Size : 107372081152
SizeRemaining : 94993174528
PSComputerName :
CimClass : ROOT/Microsoft/Windows/Storage:MSFT_Volume
CimInstanceProperties : {DriveLetter, DriveType, FileSystem, FileSystemLabel…}
CimSystemProperties : Microsoft.Management.Infrastructure.CimSystemProperties

Nothing here tells me what partition this volume resides on.

Using WMI class directly does not provide the needed information:

(Get-WmiObject -Class Win32_Volume -Filter “DriveLetter = ‘d:'”) | Select-Object *

returns more information about the volume:

PSComputerName : CM01
__GENUS : 2
__CLASS : Win32_Volume
__SUPERCLASS : CIM_StorageVolume
__DYNASTY : CIM_ManagedSystemElement
__RELPATH : Win32_Volume.DeviceID=”\\\\?\\Volume{6e7e57fb-e9c7-11e3-80bd-00155d65010c}\\”
__PROPERTY_COUNT : 44
__DERIVATION : {CIM_StorageVolume, CIM_StorageExtent, CIM_LogicalDevice, CIM_LogicalElement…}
__SERVER : CM01
__NAMESPACE : root\cimv2
__PATH : \\CM01\root\cimv2:Win32_Volume.DeviceID=”\\\\?\\Volume{6e7e57fb-e9c7-11e3-80bd-00155d65010c}\\”
Access :
Automount : True
Availability :
BlockSize : 4096
BootVolume : False
Capacity : 107372081152
Caption : D:\
Compressed : False
ConfigManagerErrorCode :
ConfigManagerUserConfig :
CreationClassName :
Description :
DeviceID : \\?\Volume{6e7e57fb-e9c7-11e3-80bd-00155d65010c}\
DirtyBitSet : False
DriveLetter : D:
DriveType : 3
ErrorCleared :
ErrorDescription :
ErrorMethodology :
FileSystem : NTFS
FreeSpace : 94993149952
IndexingEnabled : True
InstallDate :
Label :
LastErrorCode :
MaximumFileNameLength : 255
Name : D:\
NumberOfBlocks :
PageFilePresent : False
PNPDeviceID :
PowerManagementCapabilities :
PowerManagementSupported :
Purpose :
QuotasEnabled : False
QuotasIncomplete : False
QuotasRebuilding : False
SerialNumber : 950910896
Status :
StatusInfo :
SupportsDiskQuotas : True
SupportsFileBasedCompression : True
SystemCreationClassName :
SystemName : CM01
SystemVolume : False
Scope : System.Management.ManagementScope
Path : \\CM01\root\cimv2:Win32_Volume.DeviceID=”\\\\?\\Volume{6e7e57fb-e9c7-11e3-80bd-00155d65010c}\\”
Options : System.Management.ObjectGetOptions
ClassPath : \\CM01\root\cimv2:Win32_Volume
Properties : {Access, Automount, Availability, BlockSize…}
SystemProperties : {__GENUS, __CLASS, __SUPERCLASS, __DYNASTY…}
Qualifiers : {dynamic, locale, provider}
Site :
Container :

but nothing about the partition on which this volume resides.

The Get-SBVHD function in this module identifies the VHD file path of a given drive on a given VM.

to see more details type in

help Get-SBVHD -Full

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s