Remove-EmcVirtualDiskFromVm

Removes a file-based or pass-through disk from the virtual machine.

 

Syntax

Remove-EmcVirtualDiskFromVm [-Force] -VirtualMachineConfiguration <VirtualMachineConfiguration> -Location <UInt32> [-ScsiControllerId <String>] [-ScsiControllerIndex <Int32>] [-Silent] [-WhatIf] [-Confirm] [<CommonParameters>]

 

Parameters

-Force <SwitchParameter>

Attributes: Optional, Position: named

Allows the cmdlet to continue without asking for user confirmation.

 

-VirtualMachineConfiguration <VirtualMachineConfiguration>

Attributes: Required, Position: named

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

 

-Location <UInt32>

Attributes: Required, Position: named

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

 

-ScsiControllerId <String>

Attributes: Optional, Position: named

Specifies the SCSI controller ID for the specified file-based disk. You can get the virtual machine SCSI controller information 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 for the specified file-based disk. You can get the virtual machine SCSI 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.

 

-WhatIf <SwitchParameter>

Attributes: Optional, Position: named

Shows what would happen if the cmdlet runs. The cmdlet is not run.

 

-Confirm <SwitchParameter>

Attributes: Optional, Position: named

Prompts you for confirmation before executing the command.

 

<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 -Size 1GB -VhdType fixed -Path "E:\ps_test1.vhd"

TaskStatus: Started

 10% : Creating file-based disk...

100% : Successfully created FileBasedDisk

TaskStatus: Completed

 

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

C:\PS>$locations[0]

0

 

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

 

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

This example adds a file-based disk to a virtual machine and then removes it.

 

-------------- 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 -VirtualMachineConfiguration $vmconfig -ScsiControllerIndex 0

 

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

 

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

 

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

 

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

This example adds a pass-through disk to a virtual machine and then removes it.