Shortcut Menu

Skip

Main Navigation

Choose your language


ActiveXperts Network Monitor
Monitor servers, workstations, devices and applications in your network

Quicklinks


Virtual Disk Drives - Scripting

Add a DVD Drive to a Virtual Machine
Attach a DVD Host Drive to all Virtual Machines
Attach a DVD Image to all Virtual Machines
Attach a Floppy Drive to All Virtual Machines
Attach a Floppy Image to All Virtual Machines
Add a Hard Disk Connection to a Virtual Machine
Add a SCSI Controller to a Virtual Machine
Create a Floppy Image
Compact a Virtual Hard Disk
Create a Virtual Server Dynamic Hard Disk
Create a Virtual Server Fixed Hard Disk
Discard Virtual Server Undo Disks
List Virtual Machine DVD Information
List Virtual Machine Floppy Drive Information
List Virtual Machine SCSI Controller Information
List Virtual Server Floppy Image Type
List Virtual Server Hard Disk Connection Information
List Virtual Server Hard Disk Information
Merge Virtual Machine Undo Disks
Remove a Virtual Machine DVD Drive
Release a Virtual Machine DVD Image
Release a Virtual Machine Floppy Drive
Release a Virtual Machine Floppy Image
Release a Virtual Machine Host Drive
Remove a Virtual Machine SCSI Controller
Remove a Virual Server Hard Disk Connection


You can use any of the VBScript programs below in ActiveXperts Network Monitor. Click here for an explanation about how to include scripts in ActiveXperts Network Monitor.



Add a DVD Drive to a Virtual Machine


Adds a DVD drive to a Virtual Machine named Windows 2000 Server.
On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

errReturn = objVM.AddDVDROMDrive(0,1,0)
	

Attach a DVD Host Drive to all Virtual Machines


Adds a DVD drive to all the virtual machines on a computer.
On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colDVDDrives = objVM.DVDROMDrives
    For Each objDrive in colDVDDrives
        errReturn = objDrive.AttachHostDrive("D")
    Next
Next
	

Attach a DVD Image to all Virtual Machines


Attaches a DVD image to all the virtual machines on a computer.
On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colDVDDrives = objVM.DVDROMDrives
    For Each objDrive in colDVDDrives
        errReturn = objDrive.AttachImage _
            ("C:\Virtual Machines\Images\VMAdditions013107.iso")
    Next
Next
	

Attach a Floppy Drive to All Virtual Machines


Attaches a floppy drive to all the virtual machines on a computer.
On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colFloppyDrives = objVM.FloppyDrives
    For Each objDrive in colFloppyDrives
        errReturn = objDrive.AttachHostDrive("A")
    Next
Next
	

Attach a Floppy Image to All Virtual Machines


Attaches a floppy image to all the virtual machines on a computer.
On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colFloppyDrives = objVM.FloppyDrives
    For Each objDrive in colFloppyDrives
        errReturn = objDrive.AttachImage _
            ("C:\Virtual Machines\Additions\Dos Virtual Machine Additions.vfd")
    Next
Next
	

Add a Hard Disk Connection to a Virtual Machine


Adds a hard disk connection to a Virtual Machine named Windows 2000 Server.
On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")
Set objDrive = objVM.AddHardDiskConnection _
    ("c:\Virtual Machines\Windows 2000 Server Hard Disk.vhd",0,0,0)
	

Add a SCSI Controller to a Virtual Machine


Adds a SCSI controller to a Virtual Machine named Windows 2000 Server.
On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")
objVM.AddSCSIController()
	

Create a Floppy Image


Creates a new Virtual Server floppy image.
On Error Resume Next

Const vmFloppyDiskImage_HighDensity = 2

Set objVS = CreateObject("VirtualServer.Application")
errReturn = objVS.CreateFloppyDiskImage _
    ("C:\Virtual Machines\Images\\Test.vfd", vmFloppyDiskImage_HighDensity)
	

Compact a Virtual Hard Disk


Compacts all the virtual hard disks on a computer.
On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colHardDiskConnections = objVM.HardDiskConnections
    For Each objDrive in colHardDiskConnections
        Set objHardDisk = objDrive.HardDisk
        objHardDisk.Compact()
    Next  
Next
	

Create a Virtual Server Dynamic Hard Disk


Creates a new Virtual Server dynamic hard disk.
On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
errReturn = objVS.CreateDynamicVirtualHardDisk _
    ("C:\Virtual Machines\Disks\Scripted_HardDisk.vhd", 20)
	

Create a Virtual Server Fixed Hard Disk


Creates a new Virtual Server fixed hard disk.
On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
errReturn = objVS.CreateFixedVirtualHardDisk _
    ("C:\Virtual Machines\Disks\Fixed_HardDisk.vhd", 20)
	

Discard Virtual Server Undo Disks


Discards the undo disks for a virtual machine named Windows 2000 Server.
On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")
objVM.DiscardUndoDisks()
	

List Virtual Machine DVD Information


Lists DVD information for all the virtual machines on a computer.
On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colDVDDrives = objVM.DVDROMDrives
    For Each objDrive in colDVDDrives
        Wscript.Echo "Virtual machine: " & objVM.Name
        Wscript.Echo "Attachment: " & objDrive.Attachment
        Wscript.Echo "Bus number: " & objDrive.BusNumber
        Wscript.Echo "Bus type: " & objDrive.BusType
        Wscript.Echo "Device number: " & objDrive.DeviceNumber
        Wscript.Echo "Host drive letter: " & objDrive.HostDriveLetter
        Wscript.Echo "Image file: " & objDrive.ImageFile
        Wscript.Echo
    Next
Next
	

List Virtual Machine Floppy Drive Information


Lists floppy drive information for all the virtual machines on a computer.
On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colFloppyDrives = objVM.FloppyDrives
    For Each objDrive in colFloppyDrives
        Wscript.Echo "Virtual machine: " & objVM.Name
        Wscript.Echo "Attachment: " & objDrive.Attachment
        Wscript.Echo "Drive number: " & objDrive.DriveNumber
        Wscript.Echo "Host drive letter: " & objDrive.HostDriveLetter
        Wscript.Echo "Image file: " & objDrive.ImageFile
        Wscript.Echo
    Next
Next
	

List Virtual Machine SCSI Controller Information


Lists SCSI controller information for all the virtual machines on a computer.
On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colSCSIControllers = objVM.SCSIControllers
    For Each objController in colSCSIControllers
        Wscript.Echo "Virtual machine: " & objVM.Name
        Wscript.Echo "ID: " & objController.ID
        Wscript.Echo "Is bus shared: " & objController.IsBusShared
        Wscript.Echo "SCSI ID: " & objController.SCSIID
        Wscript.Echo
    Next
Next
	

List Virtual Server Floppy Image Type


Lists the image type for a virtual server floppy image.
On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
strImageType = objVS.GetFloppyDiskImageType _
    ("C:\Virtual Machines\Images\Dos Virtual Machine Additions.vfd")
Wscript.Echo "Image type: " & strImageType
	

List Virtual Server Hard Disk Connection Information


Lists hard disk connection information for all the virtual machines on a computer.
On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colHardDiskConnections = objVM.HardDiskConnections
    For Each objDrive in colHardDiskConnections
        Wscript.Echo "Virtual machine: " & objVM.Name
        Wscript.Echo "Bus number: " & objDrive.BusNumber
        Wscript.Echo "Bus type: " & objDrive.BusType
        Wscript.Echo "Device number: " & objDrive.DeviceNumber
        Set objHardDisk = objDrive.HardDisk
        Wscript.Echo "Hard disk file: " & objHardDisk.File
        Wscript.Echo "Host drive identifier: " & _
            objHardDisk.HostDriveIdentifier
        Wscript.Echo "Host free disk space: " & objHardDisk.HostFreeDiskSpace
        Wscript.Echo "Host volume identifier: " & _
            objHardDisk.HostVolumeIdentifier
        Wscript.Echo "Size in guest: " & objHardDisk.SizeInGuest
        Wscript.Echo "Size on host: " & objHardDisk.SizeOnHost
        Wscript.Echo "Type: " & objHardDisk.Type
        Set objUndoDrive = objDrive.UndoHardDisk
        Wscript.Echo "Hard disk file: " & objUndoDrive.File
    Next  
Next
	

List Virtual Server Hard Disk Information


Lists the disk type for a Virtual Server hard disk.
On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objHardDisk = objVS.GetHardDisk _
    ("C:\Virtual Machines\Disks\Windows 2000 Server Hard Disk.vhd")
Wscript.Echo "Hard disk type: " & objHardDisk.Type
	

Merge Virtual Machine Undo Disks


Merges undo disks for a virtual machine named Windows 2000 Server.
On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")
objVM.MergeUndoDisks()
	

Remove a Virtual Machine DVD Drive


Removes all the DVD drives for a virtual machine named Windows 2000 Server.
On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

Set colDVDDrives = objVM.DVDROMDrives
For Each objDrive in colDVDDrives
    errReturn = objVM.RemoveDVDROMDrive(objDrive)
Next
	

Release a Virtual Machine DVD Image


Release a DVD image for a virtual machine named Windows 2000 Server.
On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

Set colDVDDrives = objVM.DVDROMDrives
For Each objDrive in colDVDDrives
    errReturn = objDrive.ReleaseImage()
Next
	

Release a Virtual Machine Floppy Drive


Release the floppy drives for all the virtual machines on a computer.
On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colFloppyDrives = objVM.FloppyDrives
    For Each objDrive in colFloppyDrives
        errReturn = objDrive.ReleaseHostDrive()
    Next
Next
	

Release a Virtual Machine Floppy Image


Release the floppy images for all the virtual machines on a computer.
On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colFloppyDrives = objVM.FloppyDrives
    For Each objDrive in colFloppyDrives
        errReturn = objDrive.ReleaseImage()
    Next
Next
	

Release a Virtual Machine Host Drive


Release the host drives for all the virtual machines on a computer.
On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
set colVMs = objVS.VirtualMachines

For Each objVM in colVMS
    Set colDVDDrives = objVM.DVDROMDrives
    For Each objDrive in colDVDDrives
        errReturn = objDrive.ReleaseHostDrive
    Next
Next
	

Remove a Virtual Machine SCSI Controller


Removes all the SCSI controllers for a virtual machine named Windows 2000 Server.
On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")
Set colControllers = objVM.SCSIControllers

For Each objController in colControllers
    objVM.RemoveSCSIController(objController)
Next
	

Remove a Virual Server Hard Disk Connection


Removes all the hard disk connections for a virtual machine named Windows 2000 Server.
On Error Resume Next

Set objVS = CreateObject("VirtualServer.Application")
Set objVM = objVS.FindVirtualMachine("Windows 2000 Server")

Set colConnections = objVM.HardDiskConnections
For Each objConnection in colConnections
    objVM.RemoveHardDiskConnection(objConnection)
Next