使用powercli批次更換VM datastore

參考資料: http://winblog.ch/2012/03/19/finding-and-updating-virtual-machines-with-outdated-tools-on-vsphere-using-powershell/

Connect-VIServer -Server 10.10.10.200 -User admin -Password 'testpass'
$VMs=get-vm
foreach ($vm in $VMs)
{
    $VMHost_Name = $vm.vmhost.name
    if ($VMHost_Name -eq "10.10.10.11")
    {
        Write-Host "Change datastore of" $VM.Name
        Move-VM -vm $VM.Name -datastore local_240
    }
}

 

Facebook Comments Box

Leave a Reply