Gadgets
How to Move VMs in vCenter with Web Client or PowerShell
[ad_1]
Read this guide to learn how to move VMs – moving a VM’s storage or the entire VM to a new host – in vCenter.
Before moving VMs between hosts, confirm that vMotion is enabled on the VMkernel Ports for each host. To do this, follow the numbering in my screenshot below.

Then, confirm that vMotion is checked. Repeat this for all ESXi hosts in vCenter.


Option 1: Move a VM via vCenter Web Client
Option 1 of 2: Move a VM’s Storage within the Same Host
In this demonstration, I want to move the VM’s storage for the VM, y2k22template-1 from its current datastore, IPMpVMw1-datastore-2 to another datastore, iSCSIDatastore on the same ESXi hots.


- Right-click the VM and select Migrate. Then, on the migration wizard’s first page, select Change storage only.




- On the Select storage page, choose the datastore to move the VM’s files and click Next.
I’m moving my VM’s files to the iSCSI datastore shared by all hosts in my vCenter server.


- Finally, review your selections and if you’re happy, click FINISH.


While vCenter is moving the VM’s files to a new datastore, it displays the job’s progress in Recent Tasks.


Option 2 of 2: Move the Whole VM to a Different Host
To move a VM completely to a new host (including the VM’s storage) in vCenter, follow these steps:
- Search for the VM or navigate to its hots, then right-click the VM and select Migrate.


- On the first page of the wizard, select Change both compute resource and storage, then click Next to proceed to the next step.


- On the “Select a compute resource” page, select the host to migrate the VM. vCenter will perform a compatibility check.
If there is no issue and the check passes, proceed to the next step.


- Now, select a destination datastore on the new hots. Once again, vCenter performs a compatibility check.


- On the “Select networks” page, if you need to use a different VLAN or network in the new host, select it here. Otherwise, accept the defaults and continue.


- Finally, decide the CPU priority allocation for the migration, review the settings on the next page, and initiate the VM migration.




Monitor the progress of the VM move by expanding Recent Tasks at the bottom of vCenter.


Option 2: Move a VM with PowerShell
Option 2 of 1: Move a VM’s Storage within the Same Host
In this example, I will be moving the storage for the VM, IPMvCSA from the datastore, IPMpVMW2-datastore to a new datastore, iSCSIDatastore in the same ESXi host.




I have included comments before each command to explain what the command does. In PowerShell, any line that begins with # is a comment
#get the destination datastore$DestinationDatastore = Get-VMHost -Name ipmpvmw2.corp.itechguides.com | Get-Datastore -Name iSCSIDatastore
#move the VM to the datastore
Move-VM IPMvCSA -Datastore $DestinationDatastore
While the second command is running, PowerShell displays a progress bar.


Option 2 of 2: Move the Whole VM to a New Host
In this section, I’ll use PowerShell (PowerCLI commands) to move the VM, y2k22template-1 from the current host to the host, ipmpvmw1.corp.itechguides.com.


Run the three commands below to move a VM and its storage to another host or new datastore in the same host. I have added comments – comments start with # in PowerShell – before each command to explain what the command does
#get the destination datastore$DestinationDatastore = Get-VMHost -Name ipmpvmw1.corp.itechguides.com | Get-Datastore -Name IPMpVMw1-datastore-2
#Get the destination hots
$destinationVMHost = Get-VMHost ipmpvmw1.corp.itechguides.com
#move the VM to the datastore
Move-VM y2k22template-1 -Datastore $DestinationDatastore -Destination $destinationVMHost
Conclusion
Moving VMs in vCenter is a common admin task. As I showed in this guide, you can move a VM’s storage to a different datastore within the same ESXi host.
Similarly, you can move a VM completely to a new host.
In this guide, I explained how these tasks can be performed via the vCenter web client or PowerCLI PowerShell commands.
Let me know your thoughts about this guide by responding to the “Was this page helpful?” question below.
[ad_2]
Victor Ashiedu
Source link
