Mounting ISO

Dec 28, 2009 at 9:32 PM


Currently testing with dec '09 version on a Server 2008 R2 Datacenter with the Hyper-V role enabled and i have the following question:

To mount a ISO to a newly created VM i have to do the following:

  • Add-VMDrive -vm $vm -controllerID 1 -lun 0 -DVD
  • Add-VMDisk -vm $vm -controllerID 1 -lun 0 -path "H:" -DVD #H: is my physical DVD player
  • Set-VMDisk -vm $vm -controllerID 1 -lun 0 -path "F:\ISO\SETUP.ISO" -DVD

If i try:

  • Add-VMDrive -vm $vm -controllerID 1 -lun 0 -DVD
  • Add-VMDisk -vm $vm -controllerID 1 -lun 0 -path "F:\ISO\SETUP.ISO" -DVD

the following error:

Get-WmiObject : Invalid query
At C:\Program Files\modules\Hyperv\Disk.ps1:93 char:81
+                                 if ($path -match "\w:") {$path = $(Get-WmiObject <<<<  -Compu
terName $vm.__SERVER -Query "Select * From win32_cdromdrive where Drive='$path'").deviceID }
    + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], ManagementException
    + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiOb

Split-Path : Cannot bind argument to parameter 'Path' because it is an empty string.
At C:\Program Files\modules\Hyperv\Disk.ps1:101 char:27
+             if (split-path <<<<  $path) {$diskRASD.Connection = $path}
    + CategoryInfo          : InvalidData: (:) [Split-Path], ParameterBindingValidationExcepti
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.

Test-wmiResult : Failed to add ISO Disk Image to 2003DC1, return code'2003DC1' failed to add de
vice 'Microsoft Virtual CD/DVD Disk'. (Virtual machine ID 51B6CCAA-6FBB-4FA6-82E6-11C6C48E6711)
At C:\Program Files\modules\Hyperv\VMConfig.ps1:56 char:43
+             if ( ($result | Test-wmiResult <<<<  -wait:$wait -JobWaitText ($lstr_CreateHW -f
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Test-wmiResult

Is this correct behavior?

Thx for youre time.

Dec 30, 2009 at 2:30 PM

You might try the two-statement version using a UNC path (\\server\share) instead of a mapped drive.


Jan 8, 2010 at 6:07 PM

It is bug in add-VMDisk. I made a change to support mounting local drives with the effect that it breaks mounting ISOs. Yes I was stupid enough not to test it. A new build is on the way but for now please find the line that starts

if ($path -match

and change the term being tested for so it reads

if ($path -match "^\w:$")






Jan 9, 2010 at 12:35 PM

Hi James,

Thx for the reply.

I made the changes and it works fine know.