Virtual Server : Attach an ISO as a DVD Drive (Scripting)

Here is a quick function I put together:

'Name is the name of the virtual machine itself
'ISOPath is the full file path to the ISO
function AttachISOAsDVD(Name, ISOPath)

 on error resume next
 Set objVS =  CreateObject("VirtualServer.Application")
 Set objVM = objVS.FindVirtualMachine(Name)
 'add the new DVD ROM
 set objDVDDrive = objVM.AddDVDROMDrive(0,1,0)
 'attach the ISO
 objDVDDrive.AttachImage(ISOPath)

 'clean up
 set objDVDDrive = nothing
 set objVM = nothing
 set objVS = nothing

end function

More scripts can be found here at the Script Repository: Virtual Server.  If you notice there is a link in the Script Repository under Virtual Hard Disks to Add a DVD Drive to a Virtual Machine which is broken, it forwards you to the "Add a Hard Disk Connection to a Virtual Machine".  The function I posted above should be good enough to help with that if you need it.

 

1 Comment

  • Eric-Jan said

    I have problems mounting DVD's greater tyhan 4GB. This occurs in Virtual PC and Virtual Server, not in Hyper-V. Did you encounter this problem as well?

Comments have been disabled for this content.