Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 228631

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)

$
0
0

If you don't move the Export-Csv outside of the loop, you will only have data for the last VM.

 

Try this version

 

$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|Out-Null
    Shutdown-VMGuest-VM$vm-Confirm:$false|Out-Null
    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 228631

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>