Thursday, December 1, 2022

PowerCLI script to move/migrate virtual machines to datastore and convert to thin provisioning

 PowerCLI script to move/migrate virtual machines to datastore and convert to thin provisioning


Connect-VIServer vcenter-server

$input = Import-Csv C:\Temp\vmlist.csv

foreach ($row in $input)

{

    $VMName=$row.VMName

    $DSName=$row.DSName

    Move-VM -VM $VMName -Datastore (Get-Datastore $DSName) -DiskStorageFormat Thin -RunAsync

}

Disconnect-VIServer vcenter-server -Confirm:$false


<#

Content of vmlist.csv

VMName,DSName

vm1,DS1

vm2,DS8

vm3,DS6

#>

No comments:

Post a Comment