Book Image

Learning PowerCLI for VMware VSphere

By : Robert van den Nieuwendijk
Book Image

Learning PowerCLI for VMware VSphere

By: Robert van den Nieuwendijk

Overview of this book

Table of Contents (17 chapters)
Learning PowerCLI
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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 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:

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 object such as a datacenter or a folder.

In the next example, you will first put host 192.168.0.134 in maintenance mode, move the host to Cluster02, and finally exit maintenance mode:

PowerCLI C:\> $VMHost = Get-VMHost -Name 192.168.0.134
PowerCLI...