Erwin_Zavala
Contributor
Contributor

How do i thin provision the hd of a vm that is running

how do I re-write this code to on a power vm be able

1. to move hd to another datastore and thin provision it

2. reloate that vm to the new datastore

Connect-VIServer -Server xxx -User xxx -Password xxx;

#Varialble

$vms = Get-VM -Name xxxx;

$datastore = Get-Datastore -Name "VM4"

foreach ($vm in $vms) {

#thin provisions HD on new datastore

Get-VM -Name "$vm" | Get-HardDisk | Set-HardDisk -Datastore $datastore

-StorageFormat Thin;

#move the rest of vm to new store

Move-VM -VM $vm -Datastore $datastore;

}

0 Kudos
1 Reply
LucD
Leadership
Leadership

Have a go with the Move-VmThin function on PoshCode.

____________

Blog: LucD notes

Twitter: lucd22


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos