Previous Topic: dpmhv-setVMClustered (Cmdlet) Command--Set a VM in a ClusterNext Topic: dpmhv-setVMProperties (Cmdlet) Command--Set VM Properties


dpmhv-setVMDisk (Funclet) Command--Create a Drive or Disk on a Drive Controller

The dpmhv-setVMDisk command lets you create a drive or disk on a drive controller. You can use the option to connect/disconnect an image.

This command has the following format:

dpmhv-setVMDisk 
-host hostname 
-vm vmname|-vmid vmguid 
[-path pathname] 
-drive{HDD,DVD} 
-type{scsi,ide}[-id id] 
[-lun lun]
[-retval] 
[-silent]
-host hostname

Specifies the name of the Hyper-V server host.

-vm vmname

Specifies the name of the VM.

-vmid vmguid

Specifies the unique ID of the VM.

-path pathname

(Optional) Specifies the path where the drive or disk is created on a drive controller.

-drive {HDD, DVD}

Specifies the drive type that you want to assign to the VM. You can assign the following drive types:

HDD

Represents the hard drive

DVD

Represents the drive of either Compact Disk (CD) or Digital Video Disk (DVD).

-type {scsi, ide}

Specifies the controller type that you want to attach to the virtual hard disk of the VM. Hyper-V supports the following two types:

SCSI

Specify the controller type as SCSI.

IDE

Specify the controller type as IDE.

-id id

(Optional) Specifies the ID of the controller mentioned in the controller type. For controller type IDE, the value is 0 or 1. For SCSI, the value is 0,1,2, or 3 based on the number of SCSI controllers added to the VM. If no id (or -1) is specified the command chooses the first controller of the specified type that has a channel available.

Default:
-1

-lun lun

(Optional) Specifies the logical unit of the controller in the form of <type> and <id>. For IDE, value is 0 or 1, for SCSI it is including the limit [0, 63]. If no unit number (or
-1) is specified, the command chooses the available channel on the specified controller.

Default:
-1

-retval

Returns a value for further processing.

-silent

Specifies not to direct the output to the screen.

Example: Create a Virtual Drive on a SCSI Controller

This example attaches a virtual hard drive image file to the first channel on the first SCSI controller.

dpmhv-setVMDisk -host hvserver -vm TestVM -type scsi -id 0 -lun 0 -drive HDD 
-path c:\VHDs\disk.vhd

Example: Attach a DVD to a VM

This example attaches a physical DVD-ROM drive to the VM, "Test VM."

dpmhv-setVMDisk -host hvserver -vm TestVM -type ide -id 0 -lun 1 -drive DVD 
-path D:

Example: Attach a Physical Host Disk to a SCSI Controller

This example gets the physical host disks and attaches them to the first available SCSI channel.

pd=dpmhv-getPhysDisks -host hvserver -retval -silent
dpmhv-setVMDisk -host hvserver -vm TestVM -type scsi -drive HDD -path (pd[0].Path)