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

Ok, without real testing the 2 scripts as I would write them.

The first script

 

$tgtDs=Get-Datastore-NameDatastoreB
&
{foreach($vminGet-VM)){    Move-VM-VM$vm-Datastore$tgtDs-Confirm:$false
   
Shutdown-VMGuest-VM$vm-Confirm:$false
   
Remove-VM-VM$vm-Confirm:$false-DeletePermanently:$false
   
$vm|SelectName,@{N="VMX";E={$vm.ExtensionData.Config.Files.VmPathName} }} |Export-CsvC:\vm-vmx.csv-NoTypeInformation-UseCulture

 

I use a CSV file to transfer the information from vCenter 1 to vCenter 2.

 

The 2nd script, to be run on vCenter 2 could look like this

 

$portgroup=Get-VirtualPortGroup-NameVLAN15
$tgtDs=Get-Datastore-NameNormalDS

Import-Csv
  C:\vm-vmx.csv-UseCulture|%{    $vm=New-VM-Name$_.Name-VMFilePath$_.VMX-VMHost (Get-Cluster-Name  Cluster_1|Get-VMHost|Get-Random) -Confirm:$false
    Get-NetworkAdapter-VM$vm|Set-NetworkAdapter-NetworkName$portgroup.Name-Confirm:$false
    Start-VM-VM$vm-Confirm:$false
    Update-Tools-VM$vm
    Shutdown-VMGuest-VM$vm-Confirm:$false
    Set-VM-VM$vm-Versionv8-Confirm:$false
    Start-VM-VM$vm-Confirm:$false
   
Invoke-VMScript-VM$vm-ScriptText"ipconfig /release; ipconfig /renew"-ScriptTypeBat-GuestUser$user-GuestPassword$pswd
    Move-VM-VM$vm-Datastore$tgtDs-Confirm:$false
}

You will have to update the datastore names and the portgroup name.

If you don't run this with an account that has access to the guest OS, you will have to give correct values to the $user and $pswd variables.

 

A word of advise, try out this procedure first with 1 test VM !

Just change the Get-VM in the 1st script somehtin like

 

&{foreach($vminGet-VM-NameTestVM)){

Viewing all articles
Browse latest Browse all 228631

Trending Articles



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