Moving hosts to clusters
You can use the Move-VMHost
cmdlet to move a host to a cluster. The host has to already be added to your vSphere inventory. If it isn't, you can use the Add-VMHost
cmdlet to add the host to your inventory, as shown in
Chapter 4, Managing vSphere Hosts with PowerCLI
. The host also has to be in a maintenance mode or you will get the error message: The operation is not allowed in the current state.
The syntax of the Move-VMHost
cmdlet is as follows:
Move-VMHost [-VMHost] <VMHost[]> [-Destination] <VIContainer>
[-Server <VIServer[]>] [-RunAsync] [-WhatIf] [-Confirm]
[<CommonParameters>]
The -VMHost
and -Destination
parameters are required.
You can also use the Move-VMhost
cmdlet to move a host to another VIContainer such as a data center or a folder.
In the following example, you will first put host 192.168.0.134
in a maintenance mode, move the host to Cluster02,
and finally exit a maintenance mode:
PowerCLI C:\> $VMHost =...