Add-EmcPassthroughDiskToVirtualMachine

Adds or attaches a pass-through disk to a virtual machine.

 

Syntax

 

Parameters

-DiskId <String>

Attributes: Required, Position: named

Specifies the pass-through disk identifier in the hypervisor.

 

-VirtualMachineConfiguration <VirtualMachineConfiguration>

Attributes: Required, Position: named

Specifies the ESI virtual machine configuration object, which you can get from the ESI hypervisor host system VirtualMachinesConfigurations parameter or by using the Get-EmcVirtualMachineConfiguration cmdlet.

 

-Location <UInt32>

Attributes: Required, Position: named

Specifies the available location or LUN number of the specified SCSI controller for adding the file-based disk. You can get the available SCSI controller location from the virtual machine hypervisor object or by using the Get-EmcAvailableScsiControllerLocation cmdlet.

 

-ScsiControllerId <String>

Attributes: Optional, Position: named

Specifies the SCSI controller ID for attaching the specified file-based disk. You can get the ID from the ESI hypervisor object or by using the Get-EmcVirtualMachineScsiController cmdlet.

 

-ScsiControllerIndex <UInt32>

Attributes: Optional, Position: named

Specifies the SCSI controller zero-based index to add or attach a specified file-based disk. You can get the virtual machine controller information from the ESI hypervisor object or by using the Get-EmcVirtualMachineScsiController cmdlet.

 

-Silent <SwitchParameter>

Attributes: Optional, Position: named

Turns off all the informational and verbose messages. However, it still displays errors.

 

-DiskNumber <UInt32>

Attributes: Required, Position: named

Specifies the pass-through disk number in hypervisor.

 

-HostDisk <Disk>

Attributes: Required, Position: named

Specifies the ESI host disk object, which you can get from the ESI host system object or by using the Get-EmcHostDisk or Find-EmcHostDisk cmdlets.

 

-ScsiLun <ScsiLun>

Attributes: Required, Position: named

Specifies the ESI ScsiLun object. A ScsiLun object can be obtained by using a ESI Storage System object or by using the Get-EmcScsiLun cmdlet.

 

-Persistence <VirtualDevicePersistence>

Attributes: Optional, Position: named

Specify VMware virtual disk mode. Valid values are Persistent, IndependentPersistent, and IndependentNonPersistent.

 

-Compatibility <RDMCompatibilityMode>

Attributes: Optional, Position: named

Specifies the compatibility modes for raw disk mappings. Valid values are Physical and Virtual.

 

-Datastore <Datastore>

Attributes: Optional, Position: named

Specifies the ESI VMware datastore object, which you can get by using the Get-EmcDatastore cmdlet.

 

<CommonParameters>

This cmdlet supports these common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, and OutVariable. Type get-help about_commonparameters for more details.

 

Examples

-------------- Example 1 --------------

C:\PS>$hyperv = Get-EmcHostSystem *.133

C:\PS>$hyperv.Model

Hyper-V, PowerEdge R710

C:\PS>$vm = Get-EmcHostSystem *.148

C:\PS>$vm.Model

Virtual Machine

C:\PS>$hyperv.RefreshVirtualMachinesConfigurations()

C:\PS>$vmconfig = $vm | Get-EmcVirtualMachineConfiguration; $vmconfig

C:\PS>$locations =Get-EmcAvailableScsiControllerLocation -Hypervisor $h -VirtualMachineConfiguration $vmconfig -ScsiControllerIndex 0

C:\PS>$diskConfig = Add-EmcPassthroughDiskToVirtualMachine -Hypervisor $h -VirtualMachineConfiguration $vmconfig -HostDisk $hyperv.AvailablePassthroughDiskCandidates[0] -Location $locations[0]

C:\PS>$hd = Find-EmcHostDisk -VirtualMachine $vm -VmDiskConfig $diskConfig

C:\PS>Remove-EmcVirtualDiskFromVm -Hypervisor $h -VirtualMachineConfiguration $vmconfig -Location $locations[0] -force

This example adds or attaches a pass-through disk to a virtual machine (VM), gets a hypervisor and VM system objects, refreshes VM configurations in the hypervisor, gets the VM configuration, gets the available locations of the SCSI controller, adds or attaches one of the pass-through disk candidates to the VM, finds the added or attached pass-through disk in the VM, and then removes the disk.

 

-------------- Example 2 --------------

C:\PS>$h = Get-EmcHostSystem *.133

C:\PS>$h.Model

Hyper-V, PowerEdge R710

C:\PS>$vm = Get-EmcHostSystem *.148

C:\PS>$vm.Model

Virtual Machine

C:\PS>$h | Update-EmcSystem -Silent

C:\PS>$vmconfig = $vm | Get-EmcVirtualMachineConfiguration

C:\PS>$locations =Get-EmcAvailableScsiControllerLocation -Hypervisor $h -VirtualMachineConfiguration $vmconfig -ScsiControllerIndex 0

C:\PS>$passthroughDisks = $h | Get-EmcAvailablePassthroughDiskCandidate

C:\PS>$diskConfig = Add-EmcPassthroughDiskToVirtualMachine -Hypervisor $h -VirtualMachineConfiguration $vmconfig -HostDisk $passthroughDisks[0] -Location $locations[0]

C:\PS>$hd = Find-EmcHostDisk -VirtualMachine $vm -VmDiskConfig $diskConfig

C:\PS>Remove-EmcVirtualDiskFromVm -Hypervisor $h -VirtualMachineConfiguration $vmconfig -Location $locations[0] –force

This example adds or attaches a pass-through disk to a virtual machine, similar to the first example. However, this example uses the Update-EmcSystem cmdlet to refresh virtual machine configurations in the hypervisor and uses the Get-EmcAvailableEmcPassthroughDiskCandidate cmdlet to get the pass-through disk candidates.

 

-------------- Example 3 --------------

C:\PS>$esxhost = Get-EmcESXHost *99

C:\PS>$vm = Get-EmcHostSystem *.229

C:\PS>$vm.Model

Virtual Machine

 

C:\PS>$esxhost | Update-EmcSystem

C:\PS>$vmconfig = $vm | Get-EmcVirtualMachineConfiguration; $vmconfig

C:\PS>$scsicontroller = Get-EmcVirtualMachineScsiController -VirtualMachineConfiguration $vmconfig

 

C:\PS>$locations = Get-EmcAvailableScsiControllerLocation -VirtualMachineConfiguration $vmconfig -ScsiControllerIndex 0

 

C:\PS>$scsiluns = Get-EmcAvailablePassthroughDiskCandidate -Hypervisor $esxhost

C:\PS>$datastore = Get-EmcDatastore *mydatastore*

 

C:\PS>$diskConfig = Add-EmcPassthroughDiskToVirtualMachine -ScsiLun $scsiluns[0] -Persistence Persistent -Compatibility Physical -Datastore $datastore -VirtualMachineConfiguration $vmconfig -Location $locations[0] -ScsiControllerIndex 0

This example adds, or attaches, a pass-through disk to a virtual machine and removes it. It then gets VMware and virtual machine system objects, updates them, gets the virtual machine configuration, gets the available locations of the SCSI controller, gets the datastore, and adds one of the SCSI LUNs to the virtual machine with the specified Persistence and Compatibility modes.