Help the migration of virtual machines

My company is changing the data center in a co-location facility.  How the migration is performed, there are ESXi hosts and storage shared at Camp already.  Data warehouses are replicated to the storage to the camp of data stores with the same name.  The plan was to stop the virtual machines in the data center, removal of the inventory, browse the data store of one of the colo ESXi servers and add the virtual machine to inventory... Rinse and repeat.

The problem we encountered had to do with the fact that each virtual machine has VMDK on several data stores.  This process only acknowledged the change of the primary VMDK, VMX file was always looking for 2 other volumes on the old warehouses of data, which could not be accessed camp.

I have to think that there is a way to generate scripts to avoid this problem to occur.  If we know the identifier for the new storage volume, we should be able to generate scripts, Yes?

I would like the script to read the VM names from a txt file, remove the virtual machine from the inventory on host1, browse the host2 data store (which is at Camp) and add the machine virtual inventory and then remove and re-add the other volumes, based on the name of the data store (if hard disk 2 is on datastore2 then use 9d0fac87...)

Any help would be grately appreciated!

Thanks in advance!

-Ben

Hello, BenLiebowitz-

I looked through your script.  You were just on a good amount of it.  There are a couple of things to tweak and a number of things to correct.  Here is the script of update from what I've seen would / should change (and here is the explanation of the things that I've changed the code).

# export list of Staging VMsGet-Folder -Name "Staging" | Get-VM | select Name | Sort Name | Export-CSV "c:\staging.csv" -NoTypeInformation

# Get Staging VMs$stg = Get-Folder -Name "Staging"

 # Shutdown VMs (cleanly)$stg | Get-VM | Shutdown-VMGuest -Confirm:$false

# Remove Hard Disk 2 and 3$stg = $null$stg = Get-Folder -Name "Staging"    ## getting Staging folder again$hdName2 = "Hard disk 2"$hdName3 = "Hard disk 3"$stg | Get-VM | Get-HardDisk -Name $hdName2,$hdName3 | Remove-HardDisk -Confirm:$false

# Remove VMs from InventoryGet-Folder -Name "Staging" | Get-Inventory | Remove-Inventory -Confirm:$false

## then, disconnect from the vCenter to which you were connected

## then, when connected to the vCenter server in the co-location facility:# Add VMs to Inventory$esxhost = "prpp6-vmwhst23.i3global.net"$datastore1 = "someDatastoreName" ## need to set this value!

## and, add hard disks back to VMsforeach ($row in (Import-Csv c:\staging.csv)) {    $vmName = $row.Name    $vmxfile = "[$datastore1] $vmName/$vmName.vmx"    $vmNewVM = New-VM -VMFilePath $vmxfile -VMhost $esxhost

    # Add hard Disks 2 and 3    New-HardDisk -VM $vmNewVM -DiskPath "[transient_deviceid] $vm/$vm.vmdk"    New-HardDisk -VM $vmNewVM -DiskPath "[data_deviceid] $vm/$vm.vmdk"} ## end foreach

Comments about what I've updated / changed:

  • To stop the virtual machines, you should be able to all channel the results of Get - VM directly to Shutdown-VMGuest (I rewrote which)
  • to remove the hard drive, 2 and 3, you can use the cmdlet Remove-hard drive and do it in the pipeline (I rewrote which)
    • the ' $vm = Get - VM $stg | Get-show"line in the foreach loop was going to be problematic, as you had: '$vm' contains managed objects views for all the virtual machines in the folder of staging, not only of the virtual machine currently being acted on this iteration, so things have been broken
  • the remove inventory line, you might want to add "-confirm: $false", as the default behavior may be at the request of confirmation
  • the "$esxhost = prpp6 - vmwhst23.i3global .net' line needed quotes the host name
  • you do not use the $fields variable anywhere, which can be removed
  • I've renamed the variable '$add' to '$row' for a little more clarity
  • in the part that adds the virtual machines to the inventory in the co - lo vCenter:
    • the part that tries to set the value of "$vm" is not quite right; I've updated that (and changed the name of the variable "$vmName" for clarity)
    • you did not initialize the variable "$datastore1" - you must set a value for it (and how you use it assumes that all of the virtual machines in the co - lo facility are on the same data store - is this the case?)
    • you need square brackets around the name of store data and quotes around the value for $vmxfile
    • for the call of New - VM, you might consider providing a folder with - location (if you want the VMs newly saved to a particular folder)
    • for calls of New-hard drive, you need quotes around the value - DiskPath

I would give that a shot with just a single machine and see how things are going.  Let us know the result.

Tags: VMware

Similar Questions

  • Require a process step by step for the migration of virtual machines to new VMware ESX hypervisor

    Hello

    I'm looking for the method step by step for the migration of virtual machines to new host ESX Migration both cold and hot.

    Scenario - I have two data centers running ESX host stand-alone (with VM) in Europe. I need to build the new ESX host in new Dataceter to Singapore.

    Need prerequisites, the methods available for migrate VMWARE virtual has new host ESX (in the new data center) with minimum downtime.

    It will be great if you can enumerate the markets or redirect me to documentation that I can use to create detailed steps as the target host compatibility check on VMs and so on.

    Please advice

    Concerning

    AVI

    The steps are correct. The virtual machine must be turned off (step 3).

  • How to migrate a virtual machine from the server with DAS to another server

    Hi guys,.

    questions. 'More' essential Kit. VMotion is available

    I have 2 physical servers, two of them have DAS (not SAN Central). SO I want to migrate a virtual machine on server A to server B. is it possible in this situation?

    Or should I have versions of more expensive VMWare do?

    Thank you
    Dmitry

    You can use clone. I would close first to the bottom of the virtual machine, but a VM slowed would be very nice clone. You can also use the VMware conveter. VMware converter can make a hot clone, including synchronization of last-minute changes, stop the source machine and put under tension the clone.

  • HELP - how to get the number of virtual machines on a data store?

    Looking at the inventory of the data store in the VI client, there are a "number of Virtual Machines:" according to the General information for the Summary tab... I'm looking for a script that retrieves this information for me...

    I started the script but I'm stuck... I am very new on this...

    Get-Datastore. WHERE-object {$_ .name - like "wlp" ' "} #this gives me all the data which are not local warehouses

    Could someone give an overview on how to script to retrieve the number of virtual machines on data warehouses...

    Thank you, Lee

    Sorry, something went wrong with the copy - paste

    Get-Datastore | where {$_.Name -like "vmfs*"} | Sort-Object -Property Name | %{$_ | select @{N="DSname"; E={$_.Name}},
                                                                          @{N="VMcount";E={($_ | Get-VM | Measure-Object).count}}}
    
  • How to migrate a virtual machine of vsphere vsphere 4 5

    I have a vsphere 4 and a 5 of vsphere, I want to migrate a virtual machine of vsphere vsphere 4 5

    my method is export ovf model and deploy the model of the FVO in vsphere 5, but it shows "end of file EGGS reached while looking for: * hard.

    How can I work my problem

    Thank you very much

    Hello

    Why are you trying with VMware Converter?

    https://my.VMware.com/Web/VMware/info/slug/infrastructure_operations_management/vmware_vcenter_converter_standalone/5_0

    It's the right tool for this kind of tasks/migration

    However, if you share with us details about your environment, we can help you more accurately.

    Concerning

  • Migrate a Virtual Machine like a physical machine

    Here's my situation...

    I had a virtual machine on a Virtual Infrastructure environment.  I wanted to migrate this virtual machine to another ESX environment.  The source environment is maintained by our IT Department and they will not help us or give us access to their environment.  Now we have a local administrator on the computer, virtual access, we decided to migrate the virtual computer as if it were a physical machine (physical machine to the coverter drop-down selection and installation of the agent on the source VM and when you are done uninstalling) in order to bypass interaction with HER.  The virtual machine migrated but very well and seems to work very well.  My question is, is there any potential problems migrating a virtual machine in this way (drivers, hardware, etc.)?

    Thank you!

    Your only way out is the it Department

  • Problem with Migration hot virtual machines Hyper-V

    Dear support

    I am facing problem in Live Migration of Virtual Machine in Windows 2012 of Hyper-V R2 cluster. Here are the details for my current setup.

    Two windows 2012 R2 Datacenter even care Server (HV01 and HV02) both in cluster

    A Virtual Machine created the Volume share of Cluster (c:\Cluster storage\...)

    A network adapter dedicated to the management of server-> 10.0.1.11 (HV01) and 10.0.1.13 (HV02)

    A network card dedicated to Hyper v Virtual Machines-> 10.0.1.12 (HV01) and 10.0.1.14 (HV02) and allow networking option is disabled.

    A network card for the heart beats-> 10.0.20.1 (HV01) and 10.0.20.2 (HV02)

    A network card dedicated for Live Migration-> 10.10.10.50 (HV01) and 10.10.10.51 (HV02) and chosen to be used only for the live migration fails on cluster network settings

    I added the Virtual Machine Cluster Failover successfully without error or warning. When I do a quick migration his works fine but when I do live migration his error giving 21502.

    Please update what's wrong with my setup

    Hello

    Post your question in the TechNet Server Forums, as your question kindly is beyond the scope of these Forums.

    http://social.technet.Microsoft.com/forums/WindowsServer/en-us/home?category=WindowsServer

    See you soon.

  • Report on the number of virtual machines by datastore

    Hello

    I use vFoglight 6.6.2. I try to have a report generated every week that contains the number of virtual machines running in the data store. But I don't know how to create a table of edge/report for these details.

    request for expert assistance.

    The following query gives you so all virtual machines on the specified data store

    Using the following mandatory input parameters:

    {VMWDatastore}: type foglight - 5:VMWDatastore

    Select objects of type Machine virtual VMware in parameter {VMWDatastore}

    root of {VMWDatastore} / virtualCenter/virtualMachineCollection/virtualMachines

    where:

    ({VMWDatastore} to /datastores and)

    (/ vmState/current/value is equal to "receiving")

    Like query UI setup will allow you to use it as a dashboard of entry.

    Try around with the request and let me know if this help.

    Best regards

    hEINER

  • How to import the list of virtual machines to complete a table in a workflow

    When you run the followingworkflow/library/vCenter/batch/run a workflow on a selection of objects

    How import you a list of virtual machines to complete the table of virtual machines?

    At this moment we are manually by selecting the virtual machines and adding them to the table individually which is very tedious. We would simply import a list.

    There is a certain ways that you can do what you're trying to do, but from your description, it looks like a wrapper will work best.  I enclose a simple workflow that loads the table from a csv file.  There is no error checking going on, but it should help you get started and you can expand on it from there.

  • Migration of virtual machines to vSphere 4.1 to vSphere 6.0

    As the title eludes to, we are standing up a new physics 6.0 Server vCenter Server and need to migrate virtual machines of 4.1 6.0 guest hosts.  I'd love to take the time to create a script that does the following; However, before heading down this path, I wanted to do a ping of the group to see if someone has done something like this before or have pointers to scripts that perform some of these actions already.  Some background and concept:

    • Running 4.1.
    • A new physical Center of vCenter 6.0 will be deployed side-by-side with 4.1.
    • The existing configuration of vSphere HA allows for 1-2 guests down without impact to the virtual machines.
    • The two environment and will be Cisco N1KV, SAN access shared for the same data storages.
    • A new vCenter will be lifted.
    • A single host is identified and VMs evacuated to the remaining hosts.
    • This host will be in maintenance mode, removed from the cluster and close.
    • A clean install of ESXi 6 will be done and set up spec.
    • N1KV will be deployed.

    To digress on the details at the moment... Now markets PowerCLI desired.  This idea is ad hoc and on the fly, so as I write this.

    • identify all the virtual machines associated with a specific data store - will need to work with the local client to schedule downtime for virtual machines
    • Stop the virtual machine
    • Remove the VM of the vCenter 4.1 inventory
    • to connect to vCenter 6.0
    • Add the virtual machine to the vCenter 6.0 inventory (and once we have passed the first host in the new cluster, automatically place the virtual machine by using the DRS)
    • Reconfigure the vmnic with the new Cisco 1000V dvs (will be the same name on both sides, but has a different ID)
    • pull in the keys and the values to a CSV and advancedsetting set to harden
    • Turn on the virtual machine
    • Perhaps a test of ping for the NETWORK card to check connectivity

    The order in which the steps are performed can be switched around, as long as the desired end result is the same: migration effectively virtual machines between two disparate solutions with single medium sharing as a data store.  In which I realize will always be VMFS3.  New data stores VMFS-5 is another task for another time.

    Thank you for your time, suggestions, links, etc...

    @LucD - hi.

    These steps are quite possible with PowerCLI.

    See the script after skeleton, he probably needs some adjustments to fit your environment and requirements

    $dsName = "xyz".

    $vm = get - VM - $dsName data store

    Stop-VMGuest - VM $vm - confirm: $false

    Remove-VM - $vm VM - confirm: $false

    Disconnect-VIServer-Server vc41 - confirm: $false

    $vc6 = Connect-VIServer-Server vc6

    $newVM = $vm | New-VM - DiskPath $_. ExtensionData.Config.Files.VmPathName - confirm: $false

    # Suppose a CSV file with

    # Key, value

    # key1, value1

    # key2, value2

    $advSettings = import-Csv - UseCulture advSettings.csv

    {foreach ($obj in $newVM)

    $advSettings | %{

    Get-AdvancedSetting - $obj entity - name $_. Key |

    Game-AdvancedSetting - value of $_. Value - confirm: $false

    }

    }

    Start-VM - $newVM VM - confirm: $false

    $newVM |

    Select Name,

    @{N = "Available"; E = {Test-Connection - ComputerName $_.} Guest.HostName - County 1 - Quiet}}

  • How to count the number of virtual machines on an ESXi server via command line

    I want to know the number of virtual machines running on ESXi. What is the command so that it...?

    "vim - cmd vmsvc/getallvms"

    This order list of the early running of the ESXi Server virtual machine, but I want the number (integer)

    Help, please...

    Thank you

    M@RK! V

    Hello

    You can use the PowerCLI command to get a VM number:

    SE connect-VIServer-Server "ESXi host or vCenter server.

    (Get-VM-location 'ESXi host') .count

    Elodie

  • The features of virtual machine that are not supported or disabled material...

    I get this error when I try to migrate virtual machines from one host to another.

    but some other virtual machines to migrate.

    What's wrong? I have

    and if the reason EVC mode I think that I can not migrating other virtual machines, am I right?

    1.jpg

    Jokerciitaw thanks for the reply, but I can't understand if you're right... How can I migrate some other virtual machines?

  • The substitution of parameters of the device when the cloning of virtual machines?

    Hello

    I'm trying to find out how I can substitute the disk space for a HARD drive or the network for an adapter in the cloning of virtual machines.
    I thought it should be in the VirtualMachineCloneSpec, but it doesn't seem to be an option for him. I forgot something?

    Thanks in advance.

    So it turns out that the code was perfectly fine, the problem is that in my lab I have always tried setting disk space on something weaker than what it was before that does not work.

    Thought, after verification of the documentation for Set-disc hard, as I wanted reconstruct this cmdlet to see what he's doing: Set - hard - drive vSphere PowerCLI cmdlets reference

    Thanks again for your help

  • Create the list of virtual machines to exclude the script through .csv file?

    Hello

    I have a script that runs all day off hours to check my VMs respect some things, like having the option to 'VM tools upgrade policy' checked. The script will export a list of virtual machines that DO NOT have this option enabled and then later to fix the problem. Now, for some specific VMS, I don't want to have the option active and want to exclude them from this review. I try to add a list of these virtual machines I want to exclude from my check script of VMTools_UpgradePolicy via a .csv file containing their names. Here's what I have:

    ##############################################
    #VMTools update during the feeding cycle - report
    ##############################################
    function Report_VMTools_UpgradePolicy {}
    $list = import-Csv "C:\VMware\PowerCLI\Scripts\EXCLUDE LIST\EXCLUDE_vmtools_upgradepolicy.csv".
    foreach ($entry in $list) {$exclude = Get-VM-name $entry. Name}
    $vms = get - Vm | where {$_.} Name - not $exclude - and (Get-View-Id $_.) {ID). Config.Tools.ToolsUpgradePolicy - eq 'manual'} | Select name
    $vms | Export-Csv "C:\VMware\PowerCLI\Scripts\REPORTS\vmtools_upgradepolicy.csv" - NoTypeInformation
    }

    The content of the EXCLUDE_vmtools_upgradepolicy.csv is as follows:

    'Name '.
    "VM1.
    "VM2.

    "VM3.

    I try to get all the virtual machines in my environment who have the ToolsUpgradePolicy - eq 'manual' (unchecked), AND which do not match any of the names on my list of exclusions (VM1, VM2, VM3). My script so far will do what I want, except that only the last entry in my list of exclusions will take into account. VM1 and VM2 will still be reported as VMs that need to be addressed.

    I'm not sure that I am taking the right approach with this, I will continue to seek a solution for what I want, but any help would be appreciated! I prefer to make my list of exclusion to a separate file, for example "EXCLUDE_vmtools_upgradepolicy.csv", because I want that other administrators to be able to just open this .csv file and add virtual machines to this list without having to touch my scripts.

    Thank you!

    Vince

    Hi Vince,.

    It is like that I think because of your statement:

    foreach ($entry in $list) {$exclude = Get-VM-name $entry. Name} -> it
    $vms = get - Vm | where {$_.} Name - not $exclude - and (Get-View-Id $_.) {ID). Config.Tools.ToolsUpgradePolicy - eq 'manual'} | Select name
    $vms | Export-Csv "C:\VMware\PowerCLI\Scripts\REPORTS\vmtools_upgradepolicy.csv" - NoTypeInformation
    }

    $exclude is a variable that contains only 1 entry., that's why you see only the last element inside. It will not be an array.

    foreach ($entry in $list) {[string []]+ $exclude = Get-VM-name $entry.} Name}

    This will fill $exclude table with entries of string that will contain the names of virtual machine.

    And when you will be comparing. I think you should use

    where {$exclude - notcontains $_.} Name - and... the rest

    Kind regards

    Greg

  • Difference between the hosts and virtual machines

    Happy new year!

    I guess that's a stupid question, but I don't know the answer to it.

    I created pools from VM. Some jobs in the pool are hosts and some virtual machines. What is the difference between the hosts and virtual machines. I thought I could only create virtual machines, but I guess I could create hosts as well. -What happened?

    Thanks for your help.

    where does say desktops are hosts?  A host is usually referring to an ESXi server.  A virtual machine is just the guest OS running on the host computer.  A pool is a group of VMs that can extend over several hosts.

    Gunnar

Maybe you are looking for