You can create a flat VDisk object and attach it to a virtual machine as a hard disk. After that, you can verify whether the operation was completed successfully.

Verify that you are connected to a vCenter Server system.

Verify that you have access to at least one virtual machine host.

Verify that there is at least one datastore mounted on the virtual machine host.


Mount the datastore on the virtual machine host and store the datastore in the $ds variable.

$vmHost = Get-VMHost 'Host-A'
$ds = Get-Datastore -RelatedObject $vmHost

Create a flat, thin-provisioned virtual disk with 2-GB capacity on the $ds datastore.

$vDisk = New-VDisk -Name 'VirtualDisk' -DiskType Flat -StorageFormat Thin -CapacityGB 2 -Datastore $ds

Create a virtual machine named VirtualMachine with one hard disk and store this virtual machine in the $vm variable.

$vm = New-VM -Name 'VirtualMachine' -VMHost 'Host-A' -Datastore $ds -DiskMB 512

Power on the $vm virtual machine.

Start-VM -VM $vm

Attach the VDisk object to the $vm virtual machine.

New-HardDisk -VM $vm -VDisk $vDisk

Verify that the VDisk object has been attached and the virtual machine now has two hard disks.

Get-HardDisk -VM $vm