Add-EmcFilebasedDiskToVirtualMachine

Adds or attaches a file-based disk to a virtual machine.

 

Syntax

Add-EmcFilebasedDiskToVirtualMachine -Path <String> [-Persistence <VirtualDevicePersistence>] [-Datastore <Datastore>] -VirtualMachineConfiguration <VirtualMachineConfiguration> -Location <UInt32> [-ScsiControllerId <String>] [-ScsiControllerIndex <Int32>] [-Silent] [<CommonParameters>]

 

Parameters

-Path <String>

Attributes: Required, Position: named

Specifies the file-based disk path.

 

-Persistence <VirtualDevicePersistence>

Attributes: Optional, Position: named

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

 

-Datastore <Datastore>

Attributes: Optional, Position: named

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

 

-VirtualMachineConfiguration <VirtualMachineConfiguration>

Attributes: Required, Position: named

Specifies the ESI virtual machine configuration object, which you can get by using the VirtualMachinesConfigurations parameter or the Get-EmcVirtualMachineConfiguration cmdlet. This object encapsulates VM configuration information, including status, MAC addresses, GUID, attached file-based disks, pass-through disks, and other disks.

 

-Location <UInt32>

Attributes: Required, Position: named

Specifies the available location or LUN number of the specified SCSI controller to add or attach 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 to add (attach) to a specified file-based disk. You can get virtual machine controller information from the ESI hypervisor object or by using the Get-EmcVirtualMachineScsiController cmdlet.

 

-ScsiControllerIndex <Int32>

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.

 

<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 | Update-EmcSystem -Silent

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

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

C:\PS>$vmconfig.VmId.guid

C4908C4C-6564-4688-B8EC-E47E7758E17E

 

C:\PS>New-EmcFileBasedDisk -Hypervisor $hyperv -SizeInGB 1 -DiskType fIXeD -Path "E:\ps_test1.vhd"

TaskStatus: Started

10% : Creating file-based disk...

100% : Successfully created FileBasedDisk

TaskStatus: Completed

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

C:\PS>$locations[0]

0

 

C:\PS>$diskConfig = Add-EmcFilebasedDiskToVirtualMachine -Hypervisor $hyperv -VirtualMachineConfiguration $vmconfig -Path "E:\ps_test1.vhd" -Location $locations[0]

The example attaches a file-based disk to a virtual machine and gets the hypervisor and virtual machine system objects. It then updates the objects, gets the virtual machine configuration, creates a file-based disk, gets the available SCSI controller locations, and attaches the created file-based disk to the virtual machine.

 

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

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

 

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

 

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

 

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

 

C:\PS>New-EmcFileBasedDisk -VmdkType "LazyZeroedThick"  -Hypervisor $esxhost -Size 1GB -Path “[mydatastore]VM-Test/filebaseddisk.vmdk"

C:\PS>$diskConfig = Add-EmcFileBasedDiskToVirtualMachine -Persistence Persistent -Datastore $datastore -VirtualMachineConfiguration $vmconfig -Location $locations[0] -ScsiControllerIndex 0 -Path “[mydatastore]VM-Test/filebaseddisk.vmdk"

This example attaches a file-based disk to a VMware virtual machine. It then gets a vSphere ESX host and virtual machine system objects, updates them, gets the virtual machine configuration, creates a file-based disk, gets the available SCSI controller locations and attaches the created file-based disk to the virtual machine.