Quantcast
Viewing all articles
Browse latest Browse all 240675

Re: We need to migrate 200 Windows XP/Windows server 2003 VM’s from one vCenter (say vCenterA vSphere 4.0) to another vCenter (vCenterB vSphere 5.0)

I noticed you placed the Export-Csv inside the loop, I think it should be like this

 

$tgtDs=Get-Datastore-Name (Read-Host"Carefully enter the target Datastore name to move, PowerOFF and unregister the VM")$VMs=Get-Content-PathC:\Scripts\VM-To-sVMotion-Unregister.txt$vmObj=Get-vm$vms
&
{foreach($vmin$vmObj){    Move-VM-VM$vm-Datastore$tgtDs-Confirm:$false
   
Shutdown-VMGuest-VM$vm-Confirm:$false
   
Write-Host"Shutting down $vm"
    # Set the amount of time to wait before assuming the remaining powered on guests are stuck    do {      # Wait for the VMs to be Shutdown cleanly      sleep5
   }
until (Get-VM$vm|Where { $_.PowerState-eq"poweredOff" })    Write-Host"$vm Shutdown Complete"
   
Remove-VM-VM$vm-Confirm:$false-DeletePermanently:$false
   
Write-Host"Unregistering $vm"    $vm|SelectName,@{N="VMX";E={$vm.ExtensionData.Config.Files.VmPathName}}  }} |Export-CsvC:\Scripts\vm-vmx.csv-NoTypeInformation-UseCulture

Viewing all articles
Browse latest Browse all 240675

Trending Articles