Hello Everyone,
I'm planning to migrate more than 2000 vms from vcenter 5.5 to 6.5 and I would to get some help here if it's possible to have a script
which.
Like first
Source :shutdown the vms, unregister and remove from inventory and not delete...
Destination : Register vm, add to inventory connect to network and schedule VM compatibility upgrade
Targeting the source/destination cluster or folder that contains vms, keep same vlan, determine the port group type (standard or distributed).
Destination part, before starting vms, connect network and if possible update
Many thanks
Patrick
I'm pretty sure LucD can help.
André
Moderator Note: Discussion moved from VMware vCenter™ to VMware PowerCLI
That would be one huge script, or, and perhaps better, multiple smaller scripts :smileygrin:
There are a number of such scripts available in this community and on the Internet.
Do you really want start from scratch?
Or start from something that already exists?
You could start by looking at some examples, and then list what is missing for your specific case.
Some examples:
In this community you will find entries with migration scripts.
Most of the time they handle a specific aspect of the migration: folders, permissions, VMs....
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I can go with an existing script to start and complete it step by step.
multiple small might too instead of huge script but I haven' found a correct script for the moment
but i'll appreciate your help
What would be the first par you want to tackle?
Datacenters & clusters, folders...
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Clusters, first to connect to the source\destination vcenter and
Source : shutdown vms, unresgister and remove from inventory
Destination : register, add to inventory, connect network and point it to datastore and start vms
If you think this is not the correct way, please i'd love an advice
# Variables
####################################################################################
# vCenter Source Details (SSO Domain A)
$SrcvCenter = "_"
$SrcvCenterUserName = 'administrator@ssodomain-a.local'
$SrcvCenterPassword = 'VMware1!'
# vCenter Destination Details (SSO Domain B)
$DstvCenter = "_"
$DstvCenterUserName = 'administrator@ssodomain-b.local'
$DstvCenterPassword = 'VMware1!'
Are you doing an in-place upgrade, meaning your datacenters, clusters. hosts, datastores, folders, permissions... will all stay the same?
Are you upgrading your ESXi nodes first?
What about datastores and Distributed switches?
Are you upgrading the VMs during the scenario? (HW version and the VMware Tools)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
everything is already in place and running we created new datacenter, cluster and folders except for datastores.
ESXi nodes upgraded already and we kept the same datastores and created new distributed switches.
And yes we are upgrading the vms during the scenarios, HW and vmware tools. We've already migrated manually 150 servers and they are running correctly
Ok, that makes it a bit less complex :smileygrin:
To summarise what I understood from your replies:
- VMs are sitting on shared storage, that is "visible" in both vCenters. Is that correct?
- a VM can be migrated by doing a unregister/register
- datacenters, clusters, ESXi nodes, folders have the same names in both vCenters
- the registration of the VM in the new vCenter can use the names of the "old" datacenter, cluster, ESXi nodes
- What about folders (type VM & Templates)? Do the VMs need to be moved to the same folders?
- what about portgroups? Do we use the same names? Or is there a mapping table?
- to upgrade the VMs (HW & VMware Tools) they need to be powered on at some point. Can this be done while connected to the network?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Sorry I answered directly your question and highlighted my answers
To summarise what I understood from your replies:
- VMs are sitting on shared storage, that is "visible" in both vCenters. Is that correct? Yes
- a VM can be migrated by doing a unregister/register = Yes and remove from inventory, once it's removed from the inventory, we can add it in the new vcenter inventory.
- datacenters, clusters, ESXi nodes, folders have the same names in both vCenters = Datacenter same names in both vcenters but different clusters names and folders names
- the registration of the VM in the new vCenter can use the names of the "old" datacenter, cluster, ESXi nodes = Actually we have one Datacenter and we kept the same name,vms but we changed cluster names, ESXi nodes
- What about folders (type VM & Templates)? Do the VMs need to be moved to the same folders? nope we changed folders too
- what about portgroups? Do we use the same names? Or is there a mapping table? = We use the same names too
- to upgrade the VMs (HW & VMware Tools) they need to be powered on at some point. Can this be done while connected to the network? Yes
For the properties that change, you will need some conversion tables.
How are these provided? In what format are they available (CSV,JSON...)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
csv, do you think there's a chance build such script?
What do you think of this script;
# Variables
####################################################################################
# vCenter Source Details (SSO Domain A)
$SrcvCenter = ""
$SrcvCenterUserName = "administrator@ssodomain-a.local"
$SrcvCenterPassword = "VMware1!"
# vCenter Destination Details (SSO Domain B)
$DstvCenter = ""
$DstvCenterUserName = "administrator@ssodomain-b.local"
$DstvCenterPassword = "VMware1!"
# vMotion Details
$vmToMigrate = 'web01' # The VM Name to migrate
$DstDatastore = 'nfs01-dc-b' # The destination datastore
$DstCluster = 'Compute Cluster B' # The destination cluster
$DstPortGroup = "" # The port group or distributed port group.
####################################################################################
# Function GetPortGroupObject
function GetPortGroupObject {
Param(
[Parameter(Mandatory=$True)]
[string]$PortGroup
)
if (Get-VDPortGroup -Name $DstPortGroup -ErrorAction SilentlyContinue) {
return Get-VDPortGroup -Name $DstPortGroup
}
else {
if (Get-VirtualPortGroup -Name $DstPortGroup -ErrorAction SilentlyContinue) {
return Get-VirtualPortGroup -Name $DstPortGroup
}
else {
Write-Host "The PorGroup '$DstPortGroup' doesn't exist in the destination vCenter"
exit
}
}
}
function Drawline {
for($i=0; $i -lt (get-host).ui.rawui.buffersize.width; $i++) {write-host -nonewline -foregroundcolor cyan "-"}
}
####################################################################################
# Connect to vCenter Servers
Connect-ViServer -Server $SrcvCenter -User $SrcvCenterUserName -Password $SrcvCenterPassword -WarningAction Ignore | out-null
write-Host -foregroundcolor Yellow "`nConnected to Source vCenter..."
Connect-ViServer -Server $DstvCenter -User $DstvCenterUserName -Password $DstvCenterPassword -WarningAction Ignore | out-null
write-Host -foregroundcolor Yellow "Connected to Destination vCenter..."
####################################################################################
# vMotion
$vm = Get-VM $vmToMigrate
$destination = Get-VMHost -Location $DstCluster | Select-Object -First 1
$networkAdapter = Get-NetworkAdapter -VM $vmToMigrate
$destinationPortGroup = GetPortGroupObject -PortGroup $DstPortGroup
$destinationDatastore = Get-Datastore $DstDatastore
$vm | Move-VM -Destination $destination -NetworkAdapter $networkAdapter -PortGroup $destinationPortGroup -Datastore $destinationDatastore | out-null
####################################################################################
# Display VM information after vMotion
write-host -foregroundcolor Cyan "`nVM is now running on:"
Drawline
Get-VM $vmToMigrate | Get-NetworkAdapter | Select-Object @{N="VM Name";E={$_.Parent.Name}},@{N="Cluster";E={Get-Cluster -VM $_.Parent}},@{N="ESXi Host";E={Get-VMHost -VM $_.Parent}},@{N="Datastore";E={Get-Datastore -VM $_.Parent}},@{N="Network";E={$_.NetworkName}} | Format-List
####################################################################################
# Disconnect
Disconnect-VIServer -Server * -Force -Confirm:$false
I thought you were not going to do this via vMotion?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
well as I'm out thoughts, now thinking to use vmotion
Ok, fair enough.
Let me know when you have decided what to do :smileygrin:
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
sorry LucD, I sound confused but I've decided to use vmotion
What do you think?
I'm not sure cross vCenter vMotion will work between 5.5 and 6.5.
See the requirements described in KB2106952
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That article is about 6.0 to 6.5
What do you suggest?
I would verify with your VMware rep if it i indeed not possible to do cross-vCenter vMotion between 5.5 and 6.5
I don't think it is, since 6.0 is the minimum requirement.
But don't take my word for it, ask around.
If cross-vCenter vMotion is not possible, you could fall back on your original plan of doing an unregister/register for each VM.
There are other migration options with backup/restore solutions offered by several vendors.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference