Several cold migration via PowerCLI on data centers

Hi all

Here's my problem.   I am trying to automate migration cold of the about 30 mV (obviously power off) of a data center to another in the same virtual Center.    I was able to migrate both through PowerCLI 1 VM by using the following script.  I used Onyx to help me with the basis for the script.

$spec = New-Object VMware.Vim.VirtualMachineRelocateSpec

$spec.datastore = New-Object VMware.Vim.ManagedObjectReference

$spec.datastore.type = 'Datastore '.

$spec.datastore.value = "datastore-1672.

$spec.pool = New-Object VMware.Vim.ManagedObjectReference

$spec.pool.type = 'ResourcePool.

$spec.pool.value = 'resgroup-4017.

$spec.host = New-Object VMware.Vim.ManagedObjectReference

$spec.host.type = 'HostSystem.

$spec.host.value = 'host-4018.

$spec.disk = New-Object VMware.Vim.VirtualMachineRelocateSpecDiskLocator [] (1)

$spec.disk [0] = New-Object VMware.Vim.VirtualMachineRelocateSpecDiskLocator

$spec.disk [0] .diskId = 2000

$spec.disk [0] .datastore = New-Object VMware.Vim.ManagedObjectReference

$spec.disk [0].datastore.type = "data store".

$spec.disk [0].datastore.value = "datastore-1672.

_this $ = Get-view -Id ' VirtualMachine-vm-4029'. "

_this $. RelocateVM_Task ($spec, "defaultPriority")

What I'm trying to do now, is to use variables for the values of the data store, pool, host and Get-View to the virtual machine itself to run a migration of more than 1 at a time.  So here's what I tried to do

to connect-viserver VCENTERSERVER.domain.local

$vms = Import-CSV "G:\temp\scripts\relocate.csv".

{foreach ($vm to $vms)

$spec = New-Object VMware.Vim.VirtualMachineRelocateSpec

$spec.datastore = New-Object VMware.Vim.ManagedObjectReference

$spec.datastore.type = 'Datastore '.

$spec.datastore.value = $vm. DatastoreName

$spec.pool = New-Object VMware.Vim.ManagedObjectReference

$spec.pool.type = 'ResourcePool.

$spec.pool.value = $vm. ResourcePoolName

$spec.host = New-Object VMware.Vim.ManagedObjectReference

$spec.host.type = 'HostSystem.

$spec.host.value = $vm. ESXHostName

$spec.disk = New-Object VMware.Vim.VirtualMachineRelocateSpecDiskLocator [] (1)

$spec.disk [0] = New-Object VMware.Vim.VirtualMachineRelocateSpecDiskLocator

$spec.disk [0] .diskId = 2000

$spec.disk [0] .datastore = New-Object VMware.Vim.ManagedObjectReference

$spec.disk [0].datastore.type = "data store".

$spec.disk [0].datastore.value = $vm. DatastoreName

_this $ = Get-view -Id $vm. Name

_this $. RelocateVM_Task ($spec, "defaultPriority")

}

Here's what my CSV file looks like.  I used PowerCLI for find the real ID for each object.

Name, DatastoreName, ResourcePoolName, ESXHostName

VirtualMachine-vm-4029,datastore-4557,resgroup-3694,HostSystem-host-3729

VirtualMachine-vm-4030,datastore-4558,resgroup-3694,HostSystem-host-3731

Here is the error message I receive when you run the script

Exception by calling 'RelocateVM_Task' with '2' or the arguments: "the object has already been deleted or was not completely created.

G:\temp\scripts\RelocateMOD.ps1:25 char: 23

+ $_C. RelocateVM_Task < < < < ($spec, "defaultPriority")

+ CategoryInfo: NotSpecified: (:)) [], MethodInvocationException)

+ FullyQualifiedErrorId: DotNetMethodException

Exception by calling 'RelocateVM_Task' with '2' or the arguments: "the object has already been deleted or was not completely created.

G:\temp\scripts\RelocateMOD.ps1:25 char: 23

+ $_C. RelocateVM_Task < < < < ($spec, "defaultPriority")

+ CategoryInfo: NotSpecified: (:)) [], MethodInvocationException)

+ FullyQualifiedErrorId: DotNetMethodException

Any help is greatly appreciated.

It's one of the drawbacks of the Onyx, the generated code is endless.

There is no need to use the ID in the CSV file, simply use the names.

And there is no need to specify a data store for the vDisk if you migrating the data store even other files such as the virtual machine

connect-viserver VCENTERSERVER.domain.local
$vms = Import-CSV "G:\temp\scripts\relocate.csv" foreach ($vm in $vms) {
  $spec = New-Object VMware.Vim.VirtualMachineRelocateSpec  $spec.datastore = (Get-Datastore -Name $vm.DatastoreName).ExtensionData.MoRef  $spec.pool = (Get-ResourcePool -Name $vm.ResourcePoolName).ExtensionData.MoRef  $spec.host = (Get-VMHost -Name $vm.ESXHostName).ExtensionData.MoRef

  $vmObj = Get-VM -Name $vm.Name | Get-View  $vmObj.RelocateVM_Task($spec, "defaultPriority")
}

And your CSV might look like this

Name, DatastoreName, ResourcePoolName, ESXHostName

VM1, DS1, Pool1 ESX1

VM2, DS1, Pool2, ESX2

Tags: VMware

Similar Questions

  • How to migrate exadata overall in data centers?

    How to migrate exadata overall in data centers? Forklift (lift & shift) is only option for this kind of migration since we are talking about migration unit?

    Best practices/experiences around these migrations?

    Thank you

    Aerts

    Hello

    We recently had a data center move and moved some exadata machines to a new location.

    There are a few things to consider before the move is going;

    (1) prepare the network on the new data center and make sure all connectivity (for example, you can remote access to it) work.  In our case, the new centre has same network IPs.

    (2) download the seller who transported material Machines.

    (3) on the last day before moving, stop the Exadata Machine (close the database, RAC nodes db stop, knots of cell, endless tape etc...)

    (4) turn off the Exadata Machine

    (5) disconnect all network cables.

    (6) let the equipment cool.

    (7) transportation to the new location and move the machine to fix the Bay and wait for the machines to be acclimated

    (8) connect the network cables.

    (9) power on Exadata.

    I found a Support which also notes, you can view; What must be done when moving Cluster nodes to a new data center (Doc ID 1332423.1)

    HTH,

    Pradeep

  • Is it possible to migrate ESXi host between data centers, if so please provide a brief not

    Hi friends,

    1. is it possible to migrate ESXi host between data centers, if so please provide a brief walking distance.

    2 can we perform vMotion and Storage vMotion while ESXi is turned on.

    3. is it possible to extend the VMDK disk while it integrates snapshots in it.

    Best regards,

    Sirot Vijay

    Yes the vmotion and svmotion works but one by one.

    1 - vmotion is posssible to power on State, but you can't svmotion the vm simultaneously. The storage will remain same

    2 svmotion is also possible to power on the State, but you cannot vmotion virtual machine simultaneously. the host will remain the same.

    3 vmotion and svmotion is possible together when the vm is off power. the host and storage can be changed simultaneously on this State.

  • Migration cold trip via lan or san?

    Assuming that VM moves to the data store CF on the same host or different host with the same access to FC storage shared... migration cold trip via lan or FC san?

    If you change data on the same host warehouses, data are transferred through HBA.  If changing hosts but vm location does not change, it changes just the host on which the virtual computer is marked (e) on.  If you change hosts and data warehouses, it goes on network.

  • Export data of material state via PowerCLI

    Hello

    I was just wondering if anyone have used PowerCLI for export the xml information of material status for a host to vCenter?

    I'm not really familiar with PowerShell and PowerCLI so I don't know if this is even possible but it would help us to completely automate some pilot third party verification.

    Thank you for your time and help

    Matt

    You can check the driver versions when you are connected to a host without the need for an XML export.

    I've attached a quick script and dirty to write versions of all the drivers in the console.

    Main points of the script:

    Connect-VIServer - Connect to vCenter

    Get-VMHost - lists associated Hosts the vCenter

    Get-EsxCli - access to the host ESX CLI

    $EsxCli.system.module.get("$DRIVER_NAME") - retrieves the VMKernel module (if the system knows about it) by name

    It's just the best way to show how to get information about the drivers. Basically you just connect the vCenter Server via PowerCLI, then connect to hosts one by one. When you are connected to a host, use EsxCli to obtain the driver information (module).

    I also forgot to add a line at the end of the script, so here it is: ' $DISCONNECT = Disconnect-VIServer $VCENTER_SERVER-force - confirm: $FALSE.

    -Ryan d. King

  • Virtual data centers how to a campus of double site?

    We begin to plan for a migration of vSphere 4.1 and 5.1.  We have two data centers several miles share a link 10 gig.  In our current setup, we have a virtual data center that includes the host esx on both sites.  VMotion and storage vmotion work well on the link 10 gig.  HA and DRS are not currently configured, but it will be included in the new configuration.  I'm looking for the advantages and disadvantages to continue having a virtual Datacenter, against two, one for each physical site that includes only the servers at this place, that is, buildling1-vdc, would include esx1 bldg1, bldg1-esx2, etc., and construction2-vdc, would include construction2-esx1, bldg2-esx2, etc.. We would be able to preserve the beaches of IPS to each site in the case of a link failure.    As I understand it, we would not power of vmotion or HA and DRS established between the two virtual data centers.  Other have a virtual infrastructure of several location connected by links broadband?  If you do, how much virtual datcenters you have and how they are configured?

    Please ask questions if you need more specific information to answer the question.

    a "Datacenter" vCenter object is a limit for the vMotion and distributed vSwitches. So, if you want to migrate virtual machines between the buildings / clusters these groups must be part of the object of data center. Also if you want to have similar networks on both sides and you want to use Distributed vSwitched then you will need to have both part of clusters of the same domain controller so that the VDS objects are pushed down.

  • How cold migration transfer VMDK file on which network indeed?

    There is an explanation, that I got from this community is cold migration transfer on service console network, the specific "service console" connects the VI client.  But this explanation cannot explain this situation below.

    Virtual Center: 138.35.170.87 (gateway: 138.35.170.1)

    ESX1: 15.171.70.10 (gateway: 15.171.70.1)

    ESX2: 15.171.70.11 (gateway: 15.171.70.1)

    ESX1 and ESX2 is under HA environment, linking SAN even with a disk of EVA storage array.

    15 171,70. * can access 138.35.170 * between them freely by the window / door entry

    15.171.70 * is the network isolation. They cannot access each other.

    Migration cold can work well in the environment.

    The vdisk to the virtual machine, we planned to migrate is dedicate to the logical unit number, and the target data store is dedicated lun as well.

    Could you tell me how cold migration works?

    Cold migration can be of different types:

    1 Datastore1-> Datastore2, ESX remains the same: copy of files only.

    2 Datastore1-> Datastore2, ESX1-> ESX2, and data warehouses are not shared: via the Service Console / VMkernel.

    3 Datastore1-> Datastore2, ESX1-> ESX2, and data warehouses are shared: I guess than filecopy and re-enter on an another ESX VM.

    ---

    VMware vExpert 2009

    http://blog.vadmin.ru

  • VMotion between data centers

    We are constructing a new environment VI 3.5 that will match our new approved conformity existing SOPS all of the virtual machine in the environment will have to be moved off the power as soon as the new cluster\datacenter is built.  I am trying to determine the practical way of best\most to do - what I'm basically not clear is if I can migrate a virtual machine between 2 data centers or not.

    Any help on how best to do that is very appreciated-

    Steve

    wouldn't that be nice.  You can always stop the virtual machine and a cold migration.

  • The Migration Wizard transfers the data of other users?

    My wife and I share a Mac as different "users." If I use the Migration Assistant to transfer data to my new Macbook Pro, it also transfers all of its side (documents, music, etc.)?

    I heard that Migration Wizard allows you to do this. I found it very complicated to set up and easy to make a mistake. Because I'm on several Macs that regularly require copies exact bootable I paid for and have used Carbon Copy Cloner from Mike Bombich https://bombich.com/

    Although the CCC4 ~ $40,-(il est compatible avec El Capitan) you can download a free 30 day trial. It is so easy to install and make a clone. I never had a hick-up using many times. There is a developer good reputation well known, you can contact at any time.

  • Custom data centers

    I created several CDC that we use for the management of capacity, but recently noticed that it does not automatically update with the new groups added to the environment in. Does anyone know how I can get a CDC auto add new members in the area which I define as my CDC

    Here it is my CDC production and as you can see the new cluster its not added. It doesn't seem to be a parent object that I can select (in this case windows or linux) that will automatically add new groups

    CDC.png

    Today, custom data centers do not have an automatic fill criteria are met that statically. However, I agree with you that it would be an advantage to have this capability, similar to the how custom groups to have rulesets. Others that the obvious benefits of Datacenter Custom ojcts be exploited with WLP capabilities, I use these global organizational construction groups of cluster for the analysis of high level. This high-level analysis is in the form of capacity planning, calculation, efficiency and so on. This cap of model capabilities are not present in custom groups (CGs simply show the distribution of the population), which make the data centres custom unique positions for the aggregation of CLuster and analysis without the need to be creative with the SMs and the views to try to make them 'cap-model-like. "

  • How to calculate the IOPS datastore / s and latency via Powercli?

    Hi all!

    I want to calculate the IOPS / s (RO/RW) and the latency of the data via Powercli store, but I cant' find this metric in Vcenter (in the data store tab) and see no metric for data via the cmdlet Get-Stat store.

    How can we measure IOPS / s and latency of data store?  For example I know veeam monitor this information - http://cdn.swcdn.net/creative/v16.8/images/screenshots/products/VM/Lg/EN/VMan60-Orion-Datastore-Top_Lg_960x540.jpg

    I know, I can get this VM or vmhost metric, but I need information on the data store.

    How to measure for IOPS / s and latency of data properly store?

    Thanks in advance!

    These measures are collected on ESXi nodes, entity would need to have the ESXi nodes where these data warehouses are connected.

    You can use the Instance property to filter.

    Under the PerformanceManager , you see all the measures for each indicator it indicates under which entity this metric is collected.

    And Yes, the cmdlet Get-inventory returns no data warehouses.

    There is a little, aggregated metric for data warehouses, I'll have to find an alternative for those.

    Nice catch!

  • Copy of models between data centers

    Hello

    I have a couple of VM being cloned to models. These models need to be copied in other data centers VMWare. I got it all to a using PowerCLI PowerShell script. If I understand well I can't do just a simple copy of a data center to another. First of all, I need to upload the template, then download to the data center target to get these models where they do.

    Does anyone have an idea how I could do this task and it is able to be accomplished using PowerCLI?

    TIA

    OK, you could do something in this direction.

    $vmName = "MyVM.

    $templateName = "template".

    $tgtDC = "dc".

    $dc = get-data center-name $tgtDC

    # Get the VM source

    $vm = get-VM-name $vmName

    # Clone VM and move it to the target DC

    New-VM - $vm - name $templateName VM | Move-VM-Destination $dc

    # Convert the VM cloned a model of

    Get-VM-name $templateName | Set-model

  • Merger of two data centers separated with a different license.

    Due to the fusion of the IT departments, we have two data centers and vCenter servers.  The IP network is a network of flat class.  ISCSI are on two physically separate networks.

    Data Center 1 (DC1)

    vCenter Foundation 5.5

    3 hosts vSphere 5 Enterprise (6 cpu)

    1 series 6200 Equallogic SAN

    Data Center 2 (DC2)

    vCenter 5.1 Standard

    2 hosts vSphere 5 Enterprise (4 cpu)

    1 SAN Equallogic 4000 series

    We would like to:

    1. move the Standard of DC2 on DC1 and the license to the Foundation from DC1 to DC2 (Swap licenses)
    2. import of DC2 in vCenter on DC1 and then unmold on DC2 Foundation license.
    3. Finally have two data centers operating from DC1 vCenter running Standard Edition 5.5

    Is this possible at all?  How would we do this.

    Thanks in advance

    With licenses owned by the same company, the steps you mentioned should be ok.

    However, from a technical point of view, you can plan the migration according to the features you use. A few things you can do is to disable HA and DRS on DC2 environment before migrating the hosts to DC1 (just to avoid potential problems), and you can also make sure for example on DC2 data store names do not match the names on DC1 to avoid confusion after the migration.

    Unless the special functions are used on DC2 which must be supported before the migration, you can simply unplug the hosts of DC2 and add them to a DC1 with operational virtual machine. Host CPU licenses must move automatically with the hosts.

    André

    PS: TheSMO: licenses are based on major versions, i.e. 5.x., so there is no need to up - or their decommissioning in this case.

  • Extract alarm VCenter via PowerCLI

    Nice day!

    I have a script which collects VCenter alarms and inform me by e-mail. It collects the alarm of VM, host, the data centers with clusters, etc. But I had the alarm to the VCenter. I can't find how to extract using PowerCLI. Invites, who face this problem.

    vmware.png

    Level vCenter alarms can normally be recovered through the folder hidden data centers.

    Use the entity returned by 'Get-file-name data centers'

  • ESXi5.1 - CDP-settings via PowerCLI

    Hello

    It is possible to set the CDP-settings on an ESXi5.1 on several hosts via PowerCLI?

    And if then...?

    Thanks in advance!

    Chakoe

    I guess that (wildguess), that your vSwitches are called vSwitch. Misspelling? Case-sensitive?

Maybe you are looking for

  • Satellite X 200-disc HARD on XP and display problems

    HelloI bought a laptop computer 200 X (PSPB9E) and I have some problems.How to install XP on this machine? While trying to install Windows xp says it cannot find any hard disk.So where can I find drivers sata for this machine, or how to fix this?When

  • Siri can be used to unlock the iPhone. It still works. Please fix this bug.

    https://www.Facebook.com/100001124120764/videos/1018654068182054/ Here is the link to the video in which the person has unlocked iPhone by Siri asking time, goes to the clock app, then type the sign on the upper right corner, randomly type something,

  • Lost folder of the Start Menu Windows XP Media Center shortcuts

    My system crashed a few weeks ago and I had to get it fixed.  I lost most of my programs, but reinstalled.  Yesterday I went to run an application in the menu START and the HANDLE has been note there.  Also my Microsoft Help and Support has disappear

  • a lot of connections on 65.55.158.118 port 3544 on windows 7

    Hello In the past 3 hours, I received around 850 connections from the ip address 65.55.158.118 on port 3544, which all have been blocked by my firewall. What exactly are these connections for? I did a WHOIS on the ip and it belongs to Microsoft. UDP

  • Update blackBerry Smartphones BlackBerry OTA private question,

    Hello I bought a unlocked version BlackBerry Priv at & tNow use it on Airtel sim,Am not able to upgrade the operating system over OTA whenever I need to reload the entire operating system to upgrade to the new version.How to get the ota on my device