VMware Cloud Community
vmdavinci
Contributor
Contributor

How to migrate(vmotion) virtuals to other esx servers in an array

Hi,

I want use powershell to migrate(vmotion) virtuals to other esx servers in a ha-cluster.

I know the syntaxes to do this: *Get-VM ESX1 | Move-VM -Destination (Get-VMHost ESX2)

What's the problem you think?

When I put all the ESX servers in an array and the script is at the point to migrate all the virtuals from the source esx server to the other esx servers in the ha-cluster, the source and destination are the same.

How can I fix this? So the virtuals are migrated to the other esx servers in the array.

A part of the script:

foreach ($i in $ALL_ESXHOSTS)

{

$ESXHOST = $i.name

clear

Get-VMhost $ESXHOST | Select name, state

# Enter Maintenance mode

Get-VM | Move-VM -Destination (Get-VMHost $ESXHOST)

Set-VMHost $ESXHOST -State Maintenance | Select name, state

0 Kudos
1 Reply
vmdavinci
Contributor
Contributor

A colleague helps me to fix this.

Close Topic

0 Kudos