[Solved] New-VM : Failed to add device ‘Synthetic Disk Drive’

When you try to create a new VM with PowerShell you may get the following error:

New-VM : Failed to add device 'Synthetic Disk Drive'.
Cannot attach storage media to the controller because the specified location is in use.

The reason

The error means that the controller (and not the disk) is already used by something else.

You get this message because you are trying to attach a VHD while you specify CD as BootDevice.

The solution

There are several possibilities:

  • Change the BootDevice parameter to something else than CD
  • Create the VM with the BootDevice and add the VHD later with the Set-VM cmdlet
  • Create the VM with the VHD and set the boot device later with
    • Set-VMBios and Set-VMDvdDrive for 1st generation VMs
    • Set-VMFirmware and Add-VMDvdDrive for 2nd generation VMs
    $Params = @{
        Path            = 'C:\VM'
        Name            = 'MyComputer'
        SwitchName      = 'External'
        Generation      = '2'
        NewVHDPath      = 'C:\VHD'
        NewVHDSizeBytes = (200 * 1Gb)
    }
    $VM = New-VM @Params
    
    $DVD = Add-VMDvdDrive -VMName $VM.VMName -Path $ISOPath -Passthru
    
    Set-VMFirmware -VM $VM -FirstBootDevice $DVD

2 thoughts on “[Solved] New-VM : Failed to add device ‘Synthetic Disk Drive’

  1. “$DVD = Add-VMDvdDrive -VMName $VM.VMName -Path $ISOPath” needs “-passthru” so that $DVD gets set. Windows 10, PS v5.1.17134.228

    Like

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s